ios – 在Swift中删除NSNotification的观察者?

前端之家收集整理的这篇文章主要介绍了ios – 在Swift中删除NSNotification的观察者?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
因为viewDidUnload和dealloc()不可用,我应该在 Swift删除NSNotification的观察者?

解决方法

使用下面的方法,其功能与dealloc相同.
deinit {
    // Release all recoureces
    // perform the deinitialization
}

A deinitializer is called immediately before a class instance is deallocated. You write deinitializers with the deinit keyword,similar to how intializers are written with the init keyword. Deinitializers are only available on class types.

Swift Deinitializer

猜你在找的iOS相关文章