为什么在升级到Xcode 4.2之后MKAnnotation会显示警告 [英] Why after upgrading to Xcode 4.2 does MKAnnotation display a warning
本文介绍了为什么在升级到Xcode 4.2之后MKAnnotation会显示警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Xcode 4.1中没有问题,但是升级到Xcode 4.2时,我收到以下警告:
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'
我的代码:
@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
(如果需要);
You shouldn't change the storage type of a property, the only change you can / should make is from readonly
to readwrite
if needed;
这篇关于为什么在升级到Xcode 4.2之后MKAnnotation会显示警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文