菜鸟问题:我正在编写一个程序,它将生成一个特定的字符串,然后将其显示在不同视图控制器的文本窗口中。我一直在测试以确保代码实际上使用 NSLog 命令生成字符串,并且我知道代码按预期工作。由于某种原因,它没有跨视图控制器传输,我不知道为什么。有什么帮助吗?这是代码片段:
CreateStoryViewController.m
- (IBAction)makeStory:(id)sender
{
StoryLine *myStory =[[StoryLine alloc] init];
[myStory setStory];
self.story = myStory.plot;
NSLog(@"story is %@", self.story);//this is generating the correct story string
self.displayStoryController = [[BIDDisplayStoryViewController alloc] initWithNibName:@"DisplayStoryView" bundle:nil];
[self.view insertSubview:self.displayStoryController.view atIndex:1];
}
DisplayStoryViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
BIDCreateStoryViewController *newStory = [[BIDCreateStoryViewController alloc] init];
NSLog(@"newStory.story is %@",newStory.story);//this generates null message
self.storyDisplay.text = newStory.story;
}