Objective-C Difference between setting nil and releasing

前端 未结 4 1364
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 22:55

I\'ve learned that in dealloc you do [object release]; but in viewDidUnload (in a UIViewController subclass) you do self.object

4条回答
  •  离开以前
    2020-11-30 23:45

    If you do object = nil without [object release], that might causes memory leaking. If you do [object release] without object = nil afterwards, object becomes dangling pointer as @Jim suggested. self.object = nil is a sugar for setter function call.

提交回复
热议问题