我想创建一个游戏,基本上是让你的伙伴说一句话。你会猜到输入了什么单词。出于这个原因,我必须将guesword from 传递给FirstViewController
to SecondViewController
。
第一个视图控制器
- (IBAction)doneBtn:(id)sender {
self.guessWord = [enterTF.text lowercaseString];
NSLog (@"Guessword s %@", guessWord);
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
NSLog (@"%@", [segue identifier]);
if ([[segue identifier] isEqualToString:@"F2S"])
{
// Get reference to the destination view controller
SecondViewController *gvc = [segue destinationViewController];
// Pass any objects to the view controller here, like...
gvc.guessWord =self.guessWord;
}
}
第二个视图控制器
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"%@",guessWord);
}
在SecondViewController
猜测词中输出“null”。为什么我会为空?