Is it correct to write [self.someproperty release]
When i implement dealloc method i used to write:
[preopertyX release];
Tod开发者_开发问答ay i found this code:
[self.propertyX release];
I'm not sure that this method is completely correct. What do you think about ? (we can take as assumption that propertyX is a retained and synthesized property).
From my understanding, you should either set it to nil or you can release the instance variable.
[self setPropertyX:nil]
or
[propertyX release]
The method you list can have unwanted side effects, but if you want the side actions of your setter to happen, I suggest setting to nil.
The accepted answer here: iPhone - dealloc - Release vs. nil is pretty good.
This is a nice debate outlining, pretty vibrantly, the methods available to you.
http://iphonedevelopment.blogspot.com/2010/09/dealloc.html followed up by http://www.red-sweater.com/blog/1423/dont-coddle-your-code
You can write [self.propertyX release] if you have set propertyX retained and synthesized otherwise not
精彩评论