Search code examples
objective-ciosios5memory-managementdealloc

iOS memory management - clarifications


I know that alloc and retain will increase the reference count of an object. Is there any other different method that actually increment the reference count? And when/how does dealloc is called?


Solution

  • With these the retain count gets increased.

    1. new, however it can be seen as alloc+init.

    2. retain

    3. copy creates new object with retain count=1

    4. mutableCopy creates new object with retain count=1

    dealloc is called automatically as soon as retain count reaches to 0.