我的目标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