开发者

Why after upgrading to Xcode 4.2 does MKAnnotation display a warning

In Xcode 4.1 there was no problem, but upgrading to Xcode 4.2 I get the following warning:

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

My code:

@interface MyAnnotation : NSObject <MKAnnotation> {
    CLLocationCoordinate2D coordinate;
    NSString *subtitle;  
    NSString *title; 
}
@property (nonatomic, readonly) CLLocationC开发者_如何学Coordinate2D coordinate;
@property (nonatomic, retain) NSString *subtitle;  
@property (nonatomic, retain) NSString *title; 

-(id)initWithCoordinate:(CLLocationCoordinate2D) coordinate;

@end


Change it to:

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

The MKAnnotation protocol declares

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

You shouldn't change the storage type of a property, the only change you can / should make is from readonly to readwrite if needed;


Try converting you application to ARC using Edit -> Refactor -> Convert to Objective-C ARC

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜