2011-10-13 76 views
2

在Xcode的4.1没有问题,但升级到的Xcode 4.2,我得到以下警告后:为什么升级到的Xcode 4.2并MKAnnotation显示警告

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

这两个属性,是他们真的吗?如果是这样,为什么? – Phlibbo

+0

如果以下答案中的任何一条提出了解决方案,请点击答案旁边的复选标记以接受答案。这将有助于未来用户搜索相同问题的答案。谢谢。 – SnareChops

回答

25

将其更改为:

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

MKAnnotation协议声明

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

您不应该更改属性的存储类型,如果需要,您可以/应该做出的唯一更改是从readonlyreadwrite;

+0

谢谢!现在好了! –

+0

嗨@hypercrypt,我做了这个改变,但仍然显示19次相同的警告!声明是at_property(非原子,读写,复制)NSString * title;和at_property(非原子,读写,复制)NSString *副标题;我正在使用iOS 5.1。任何想法有什么不对? – applefreak

-1

尝试在你的代码中@end转换后您的应用程序使用ARC Edit -> Refactor -> Convert to Objective-C ARC