Settings IBOutlets to nil in dealloc

前端 未结 4 885
情话喂你
情话喂你 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:06

    Sometimes a crash is a good thing, and a quick solution would hide a deeper problem. Calling a released variable might be something you want to know about.

    The book iOS Recipes refers to this issue:

    Cleanup in -dealloc
    In addition to releasing all relevant instance variables in the -dealloc, our examples set them to nil. This practice is one of the most hotly debated topics among Cocoa programmers, and both sides of the argu- ment hold weight. This book is not meant to participate in the debate at all: we set them to nil, but that doesn’t mean you have to. If you don’t like nil-in-dealloc, feel free to leave it out of your own code.

    A quick google search found this thread:
    http://www.cocoabuilder.com/archive/cocoa/204055-why-should-we-set-ivars-to-nil-in-dealloc.html

提交回复
热议问题