我有一个非常简单的Person类,它有一个叫做名字的ivar(一个Nsstring).当我尝试在dealloc中释放这个ivar时,静态分析器给我一个奇怪的错误:
Incorrect decrement of the reference
count of an object that is not owned
at this point by the caller
我究竟做错了什么?
顺便说一句,这是我的代码:
@interface Person : NSObject { } @property (copy) Nsstring *name; @property float expectedRaise; @end @implementation Person @synthesize name,expectedRaise; -(id) init { if ([super init]) { [self setName:@"Joe Doe"]; [self setExpectedRaise:5.0]; return self; }else { return nil; } } -(void) dealloc{ [[self name] release]; // here is where I get the error [super dealloc]; } @end
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。