我的目標C初學者和Cocos2d@property和@synthesize和內存錯誤
我讀Features of use @property and @synthesize (cocos2d)
的評論是在內存錯誤引用。這些錯誤是什麼?
在我的代碼我使用:
//interface
{
CC_bla_bla *a;
}
@property(nonatomic, retain) CC_bla_bla *a;
//implementation
@synthesize a;
self.a=[CC_bla_bla load_value:123123]
//dealloc
[self.a release]
self.a = nil;
在一個類中,我總是用self.a的所有操作。那不好嗎?
在什麼意義上使用「實例變量」a?
千萬不要'[self.a release]'! 'self.a = nil'釋放'a',因此你已經釋放了'a',你可能會在某個時候崩潰。 – hypercrypt