gon*_*nco 0 iphone sdk class objective-c dealloc
我是否必须release在dealloc类的方法中调用非指针变量?
例如
@interface myClass : NSObject {
BOOL isDirty; // do i have to release this?
NSInteger hoursSinceStart; // and this?
NSDate *myDate; // i will release the pointer in dealloc
}
@property (assign, nonatomic) NSInteger hoursSinceStart; // property to release?
@property (assign, nonatomic) BOOL isDirty; // property to release?
@end
Run Code Online (Sandbox Code Playgroud)
两件事情:
您只需要保留和释放对象.BOOL和NSIntegers不是对象,它们是原始的.
你通常不应该调用release任何assign属性,因为你没有保留它 - 当然assign是唯一对NSIntegers或BOOL这样的原语有意义的类型,因为你不能保留它们.