Settings IBOutlets to nil in dealloc

前端 未结 4 855
情话喂你
情话喂你 2021-01-05 00:51

In the section titled \'Memory Warnings\' here http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmNibObjects.html, I don\'t follo

4条回答
  •  心在旅途
    2021-01-05 01:16

    Sometimes when one property becomes invalid (set to nil) we want to make other properties invalid too. If a class invalidates a property by using self.property_name=nil, then this will send a release message, which will cause a crash in dealloc if we have already called release on that property. If the invalidation occurs in a superclass, then this error is hidden and quite nasty. So whenever a superclass might invalidate a property it may be a good idea to set it to nil rather than just deallocing.

提交回复
热议问题