那么请问这个代码会不会无法成功执行?

在applicationDidEnterBackground直接NSLog的时候,是可以在退出的时候打印出来的。
但是,如果我在这个段代码里运行一个比较好性能的代码,例如回写缓存之类的。

慕姐4208626
浏览 138回答 1
1回答

小怪兽爱吃肉

这个方法本来就是用来回写缓存,保存装态之类的吧。至于时间“Your implementation of this method has approximately five seconds to perform any tasks and return. If you need additional time to perform any final tasks, you can request additional execution time from the system by calling beginBackgroundTaskWithExpirationHandler:. In practice, you should return from applicationDidEnterBackground: as quickly as possible. If the method does not return before time runs out your application is terminated and purged from memory.”默认有5秒,如果不够可以用beginBackgroundTaskWithExpirationHandler:来延长,这个我没用过,可以google一下。一般5秒应该够吧了
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

iOS