So i'm overriding dealloc method because the object is a composite object made up of one other object.
所以我重写dealloc方法,因为对象是由另一个对象组成的复合对象。
I originally had this dealloc method:
我原来有这个dealloc方法:
-(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
尼克
2 个解决方案
#1
10
They're both wrong. dealloc
returns void
, not id
:
它们都是错误的。dealloc返回无效,而不是id:
- (void) dealloc {
[rect release];
[super dealloc];
}
#2
0
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.
我刚刚检查了NSObject的引用:dealloc没有返回类型。所以,我认为定义这样一个签名是不正确的。因此,调用dealloc不应该期望返回值。
Unless you are not subclassing NSObject
...
除非你不是子类化NSObject…
#1
10
They're both wrong. dealloc
returns void
, not id
:
它们都是错误的。dealloc返回无效,而不是id:
- (void) dealloc {
[rect release];
[super dealloc];
}
#2
0
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.
我刚刚检查了NSObject的引用:dealloc没有返回类型。所以,我认为定义这样一个签名是不正确的。因此,调用dealloc不应该期望返回值。
Unless you are not subclassing NSObject
...
除非你不是子类化NSObject…