当我将变量传递给另一个视图时,它总是返回“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'