释放那是自动释放的保留财产?

问题描述

| 大家好。我为解决这个问题而头疼。我有一个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]。