如何解决释放那是自动释放的保留财产?
| 大家好。我为解决这个问题而头疼。我有一个NSNumber类型的保留属性。使用此属性时,将使用自动发布的NSNumber实例化该属性。当调用dealloc时,我获得了错误的访问权限,告诉我我正在释放已经释放的内容。这是一些代码。@interface RadarAnnotation : NSObject <MKAnnotation> {
}
@property (retain,nonatomic) NSNumber *latitude;
@end
@implementation RadarAnnotation
@synthesize latitude;
- (CLLocationCoordinate2D)coordinate
{
coordinate.latitude = [self.latitude doubleValue];
return coordinate;
}
-(void) dealloc {
[super dealloc];
[latitude release];//error is here when mapViewController is popped off stack.
}
这是我在mapViewController中实例化属性的方式:
poi.latitude = [NSNumber numberWithDouble:map.centerCoordinate.latitude];
我究竟做错了什么?非常感谢。朱尔斯
解决方法
您应该在dealloc方法的末尾调用[super dealloc]。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。