现在这是set方法:
-(void) setEngine:(Engine *) newEngine
{
[engine release];
engine = [newEngine retain];
}
Engine *engine = [Engine new];
Car *car1 = [Car new];
[car1 setEngine:engine];
NSLog(@"%lu",[engine retainCount]);
return (0);
引用计数为什么是2,在set方法中engine不是release先变成0 了吗,然后怎么可以用它retain呢 而且还是变成了2,没天理啊
|
|