内存管理的原则

 内存管理的原则

•1    代码中不能使用retain, release, autorelease
•2   不重载dealloc(如果是释放对象内存以外的处理,是可以重载该函数的,但是不能调用[super dealloc])
•3    不能使用NSAllocateObject, NSDeallocateObject
•4   不能在C结构体中使用对象指针
•5    id与void *间的如果cast时需要用特定的方法(__bridge关键字)
•6     不能使用NSAutoReleasePool、而需要@autoreleasepool块
•7   不能使用“new”开始的属性名称 (如果使用会有下面的编译错误”Property’s synthesized getter follows Cocoa naming convention for returning ‘owned’ objects”)
原文地址:https://www.cnblogs.com/chenzq12/p/6214662.html