difference between drain, release,dealloc and retain in Objective-C/
开发者_高级运维Hi i want to know the difference between drain, release,dealloc and retain in Objective-C.
retain
increase the reference count on an objectrelease
decreases the reference on an objectdrain
is used in place of release on ONLY for NSAutoreleasePool objects due to some arcana related to the Objective C garbage collectiondealloc
is called by the system once the retainCount of an object hits 0. It is where you clean up various things your object has (like a deconstructor or finalizer). You should NEVER call it directly, except for calling[super dealloc]
at the end of yourdealloc
routines.
You really should just read through Apple's memory management documentation.
精彩评论