【发布时间】:2012-03-05 14:37:28
【问题描述】:
据我所知,如果对象的保留计数变为 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:方法返回的字符串?
【问题讨论】:
-
你到底想做什么.. :/
标签: iphone objective-c memory-management ios4 retaincount