亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

那么請問這個代碼會不會無法成功執行?

那么請問這個代碼會不會無法成功執行?

iOS
慕姐4208626 2023-04-19 19:15:13
在applicationDidEnterBackground直接NSLog的時候,是可以在退出的時候打印出來的。但是,如果我在這個段代碼里運行一個比較好性能的代碼,例如回寫緩存之類的。
查看完整描述

1 回答

?
小怪獸愛吃肉

TA貢獻1852條經驗 獲得超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秒應該夠吧了


查看完整回答
反對 回復 2023-04-21
  • 1 回答
  • 0 關注
  • 161 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號