新手問題:我正在編寫一個程序,它將生成一個特定的字符串,然後將其顯示在另一個視圖控制器的文本窗口中。我一直在測試,以確保代碼實際上使用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;
}