當我傳遞變量到另一個視圖,它總是返回 'NULL'傳遞的變量返回null
代碼Screen1.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"gotoScreen2"])
{
Screen2 *screen = [[Screen2 alloc] initWithNibName:nil bundle:nil];
Screen2.passedVar = currentVar;
NSLog(@"%@",currentVar); //these 2 line both return the correct var!
NSLog(@"%@",Screen2.passedVar);
}
}
代碼Screen2.h
@property (nonatomic,copy) NSString *passedVar;
代碼Screen2.m
@synthesize passedVar;
...
NSLog(@"%@",passedVar); //This returns 'null'