在可可中,ARC让你不必担心保留,释放,自动释放等.它还禁止调用[super dealloc].允许使用A – (void)dealloc方法,但我不确定是否/何时调用它.
我知道这对于对象等是多么好,但是我在哪里放置与我在 – (id)init中执行的malloc()匹配的free()?
例:
@implementation SomeObject - (id) initWithSize: (Vertex3Di) theSize { self = [super init]; if (self) { size = theSize; filled = malloc(size.x * size.y * size.z); if (filled == nil) { //* Todo: handle error self = nil; } } return self; } - (void) dealloc // does this ever get called? If so,at the normal time,like I expect? { if (filled) free(filled); // is this the right way to do this? // [super dealloc]; // This is certainly not allowed in ARC! }