开发者

any difference between these two dealloc methods?

So i'm overr开发者_如何学Ciding dealloc method because the object is a composite object made up of one other object.

I originally had this dealloc method:

-(id) dealloc; // Override to release the Rectangle object’s memory 
{
    [rect release];
    [super dealloc];
    return self;
}

After looking in the book I saw another answer:

{
   [rect release];
   return [super dealloc];
}

just wondering if both work equally.

Thanks,

Nick


They're both wrong. dealloc returns void, not id:

- (void) dealloc {
  [rect release];
  [super dealloc];
}


I have just checked the NSObject reference: dealloc has not return type. So, I think it is incorrect to define such a signature. Thus, call to dealloc should not expect a return value.

Unless you are not subclassing NSObject...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜