Search code examples
objective-cmemory-managementmemory-leaksretainretaincount

Some doubts about memory management in ios applicato?


  1. What is the need for retain an NSObject in ios application?

  2. What is the difference between retainCount==1,retainCount=2,.....etc?

  3. How properties can handle retaining and releasing instance variable?


Solution

    1. You need to retain an objects so that it won't get deallocated while you're using it.
    2. The higher the retain count, the more times a retain message has been sent to an object.
    3. If you declare the property correctly, assigning values to it will handle the memory management for that instance variable correctly. That might mean calling retain or release correctly for object types.

    It sure sounds like you need to read some of the documentation. Perhaps specifically the Memory Management Programming Guide?