且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

退出应用程序时,dealloc方法是否正常执行?

更新时间:2022-05-28 01:18:17

系统没有理由确保在应用程序终止时单独释放每个对象.

这样做只会浪费CPU周期,也浪费用户的时间.

There is no reason for the system to ensure that every object is individually deallocated upon application termination.

Doing so is just a waste of CPU cycles and a waste of the user's time.

应用终止后,系统将以完全自动且不可避免的方式回收该应用使用的所有资源.

When an app is terminated, all resources used by that app are reclaimed by the system in an entirely automatic and unavoidable fashion.

如果您需要在应用程序终止时发生某些事情,请使用应用程序委托的钩子执行此操作.但是不要依赖于此.用户可以一时强行重启设备或强行退出应用程序.

If you need something to happen at app termination, use the application delegate's hooks for doing so. But don't rely on that. A user may force reboot a device or force quit an application at whim.