开发者

difference between drain, release,dealloc and retain in Objective-C/

开发者 https://www.devze.com 2022-12-10 10:47 出处:网络
开发者_高级运维Hi i want to know the 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 object
  • release decreases the reference on an object
  • drain is used in place of release on ONLY for NSAutoreleasePool objects due to some arcana related to the Objective C garbage collection
  • dealloc 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 your dealloc routines.

You really should just read through Apple's memory management documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消