升级到Xcode 4.2之后为什么MKAnnotation会显示警告

时间:2011-10-13 20:30:39

标签: objective-c ios xcode mapkit

在Xcode 4.1中没有问题,但升级到Xcode 4.2我收到以下警告:

Property 'title' 'copy' attribute does not match the property inherited from 'MKAnnotation'
Property 'subtitle' 'copy' attribute does not match the property inherited from 'MKAnnotation'

我的代码:

@interface MyAnnotation : NSObject <MKAnnotation> {
    CLLocationCoordinate2D coordinate;
    NSString *subtitle;  
    NSString *title; 
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString *subtitle;  
@property (nonatomic, retain) NSString *title; 

-(id)initWithCoordinate:(CLLocationCoordinate2D) coordinate;

@end

2 个答案:

答案 0 :(得分:25)

将其更改为:

@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, copy) NSString *title;

MKAnnotation协议声明

@property (nonatomic, readonly, copy) NSString *title;
@property (nonatomic, readonly, copy) NSString *subtitle;

您不应更改属性的存储类型,如果需要,您可以/应该进行的唯一更改是从readonlyreadwrite;

答案 1 :(得分:-1)

尝试使用Edit -> Refactor -> Convert to Objective-C ARC

将您的应用转换为ARC