为什么升级到Xcode 4.2后MKAnnotation会显示一个警告?



在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

改为:

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

MKAnnotation协议声明

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

你不应该改变一个属性的存储类型,你唯一可以/应该做的改变是从readonlyreadwrite如果需要的话;

尝试使用Edit -> Refactor -> Convert to Objective-C ARC将应用程序转换为ARC

最新更新