在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
答案 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;
您不应更改属性的存储类型,如果需要,您可以/应该进行的唯一更改是从readonly
到readwrite
;
答案 1 :(得分:-1)
尝试使用Edit -> Refactor -> Convert to Objective-C ARC