传递数据并不能解决问题......当调用 AppDelegate 中的函数时,我需要从视图控制器中提取字符串数据。这是代码:
在应用委托中:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
AMViewController *viewController = [[AMViewController alloc] initWithNibName:@"AMViewController" bundle:nil];
self.xpData = viewController.xpLabel.text;
NSLog(@"Value of xpString in AD: %@", self.xpData);
}
在我的 ViewController 中,我没有使用操作来传递/检索字符串。当用户点击主页按钮时,我基本上是从 ViewController 中提取它。我这样做是因为我想在退出时保存我的数据。谢谢!