-(void) myMethod {
NSString * myString = [[NSString alloc] init]; //retainCount=1
Foo * myFoo = [[Foo alloc] initWithName:myString]; //retainCount=1
NSLog("Foo's Name:%@", [myFoo getName]);
[myFoo release]; //retainCount=0 so deallocate
[myString release]; //retainCount=0 so deallocate
}
上面这个函数里面,Foo * myFoo = [[Foo alloc] initWithName:myString]; 这也算是对myString 的一次引用啊,这是实参,我形参指向他,
就相当于一个形参指针 = myString,为什么不算一次引用呢?为什么啊? |
|