Next: Error Handling, Previous: ObjectiveC, Up: Coding Standards [Contents]
4.1 Memory Management ¶
We encourage the use of the following macros to ease retain and release
and as a convenience for managing code which should work in both a
conventional retain counting environment and one with automatic reference
counting (ARC)
- ASSIGN(object,value) to assign an object variable, performing the appropriate retain/release as necessary.
- ASSIGNCOPY(object,value) to copy the value and assign it to the object.
- AUTORELEASE(object) to add the object to the current autorelease pool so
that it will be released when the pool is destroyed/drained.
- DESTROY(object) to release an object variable and set it to nil.
- ENTER_POOL and LEAVE_POOL to bracket statements which should be performed
inside their own autorlease context.
- RELEASE(object) to decrement the retain count of an object.
- RETAIN(object) to increment the retain count of an object and return that
object.