|
I learned an interesting thing the other day about how Objective C deals with the memory management of member variables that are declared as a property. In a nutshell, if a variable is a property, it's life time is auto managed by Obj C. A great example is if you have an NSString* variable. If you set it without making it a property, you explicitly have to do a [string retain] or it will go stale. However, if you declare it as a property, it will not go stale and will stay auto-referenced for the lifetime of the object that owns it. In retrospect, this seems obvious because Objective C knows when the parent object is going away and can iterate through all property objects and release them at that point as well. However, if you don't know this and you copy example code (as I did) then you can get bit by it fairly easily. Anyway, consider yourself warned...
|