Wednesday, October 01, 2008

iPhone dev 5

SEL is data type of a selector, but couldn't really understand selectors are. Are they methods? Reference counting is called "retain counting". On alloc the retain count is 1. If the retain count reaches zero, the "dealloc" method gets called on an object and after that the memory is released. If you "copy" an object the retain count (usually?) becomes one for the copy. There are things called "autorelease pools", but their use is discouraged in iPhone. Somehow everything in the pool gets released at the same time, and somehow objects can be added to such a pool without directly referencing the pool by name (at least the sample code looked like that). App kit on Mac has some kind of autorelease pool already created in the beginning. There are some conventions on when to call release on objects. If an object is created by you, then you should also release it. If you get an object from somewhere else, you shouldn't. There was something related to class factory created object releasing that I didn't understand. alloc -> init -> usable object. In addition to allocating memory, the alloc method also sets a cool explicit "isa" property for the object, that points to the object's class. Also zeroes all properties.