Why, after upgrading to Xcode 4.2, MKAnnotation displays a warning

There was no problem with Xcode 4.1, but when 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 is:

 @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
source share
2 answers

Change it to:

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

MKAnnotation Protocol Announces

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

You cannot change the type of property storage, the only change you can / must make is from readonly to readwrite if necessary;

+25
source

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

-1
source

Source: https://habr.com/ru/post/912349/


All Articles