dealloc

Valid use of accessors in init and dealloc methods?

自闭症网瘾萝莉.ら 提交于 2019-11-26 09:26:11
问题 I\'ve heard now from several sources (stackoverflow.com, cocoa-dev, the documentation, blogs, etc) that it is \"wrong\" to use accessors and settings (foo, setFoo:) in your init and dealloc methods. I understand that there is there is a remote possibility of confusing other objects that are observing the property if you do so. (a simple example is given here) However, I have to say that I don\'t agree with this practice for the following reason: The new Objective-C runtime (the one on the

iPhone - dealloc - Release vs. nil

纵然是瞬间 提交于 2019-11-26 08:49:26
问题 Wondering if someone with experience could possibly explain this a bit more. I have seen examples of... [view release]; view = nil; ....inside the (void) dealloc. What is the difference and is one better then the other? What is the best way? When doing retainCount testing I have personally seen nil drop a count from 3 to 0 for me, but release only drops it from 3 to 2. 回答1: What you have seen is probably these: 1) [foo release]; 2) self.bar = nil; 3) baz = nil; Is releasing the object,