据我所知,如果对象的保留计数变为 0,则调用它的 dealloc。但我将保留计数设为 -1。这是什么意思?
我正在使用以下代码-
Demo *obj1 = [[Demo alloc] init];
NSString *s = [[NSString alloc] initWithString:@"mithilesh"];
NSString *s1 = [NSString stringWithString:s];
[s release];
object_setInstanceVariable(obj1, [propertyName cString], s1);
//printing retain count
NSLog(@"retain count of name = %i",[obj1.name retainCount]);
输出 :
retain count of name = -1
stringWithString方法返回的字符串:何时发布?