0
我想在调用applicationDidEnterBackground时将一些数据从一个数组保存到一个plist文件中。我想弄清楚如何从applicationDidEnterBackground方法访问我的数组。有没有最佳做法来做到这一点? 非常感谢 Marcos从applicationDidEnterBackground方法保存一些数据
我想在调用applicationDidEnterBackground时将一些数据从一个数组保存到一个plist文件中。我想弄清楚如何从applicationDidEnterBackground方法访问我的数组。有没有最佳做法来做到这一点? 非常感谢 Marcos从applicationDidEnterBackground方法保存一些数据
将代码放在实际具有数据的类中。让班级注册UIApplicationDidEnterBackgroundNotification
通知。
// Put this in the `init` method
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backgrounding) name:UIApplicationDidEnterBackgroundNotification object:nil];
// The method that gets called
- (void)backgrounding {
// save the data
}
// Put this in the `dealloc` method
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
有了这个设置你没有得到任何东西进入UIApplicationDelegate
和责任保持属于它的地方。
你做了什么研究吗?似乎是一个常见的问题 – ekims