Do you notice that Apple started to provide different kind of document for iPhone?
It is called DevPedia. It is like existing Tech Note to explain some mission specific topics. However, DevPedia is a little different. It tries explaining concepts on Cocoa programming.
For example, take a look at this article on memory management
Look at this nice diagram for memory management.
This is the 1st time Apple provides very easy diagram on memory management. One picture is better than one hundred words. This kind of diagram saves lots of time to read document.
However, it doesn’t explain the case of autorelease. I think why people have difficulty in understanding non-garbage collection scheme is due to the autorelease.
For retain/release mechanism, retain count == 1 means, there is one object/place where the counted object is used. So, when you issue “release” to an object of which retain count is 1, the retain count is decreased to 0 and destroyed.
However, for autorelease mechanism, if you create an object, its retain count is 1 ( like it was in retain/release mechanism ) and if it goes out of the scope, it will be collected to be released at the moment the autorelease pool is cleaned up. If it is still in scope, the entity which manages the autorelease pool doesn’t release the object, because there is some chance that it is still used. So, document on memory management says to retain an object which is returned by some call which set the it “autorelease”, not to lose the object. If the object is quickly used, you don’t need to retain it, but if you are going to use it on following several lines, there are some chances that it is autoreleased, i.e destroyed.
I checked if this kind of document exists for Mac, but it doesn’t. Apple people seem to work more on iPhone stuff than Mac. Yeah.. Apple is chasing money. Where money goes, they spend their time. ( Although an gizmodo article today shows that Apple still makes a lot of money from Mac business. )