在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;
你不应该改变一个属性的存储类型,你唯一可以/应该做的改变是从readonly
到readwrite
如果需要的话;
尝试使用Edit -> Refactor -> Convert to Objective-C ARC
将应用程序转换为ARC