首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不相容类型'id<MKAnnotation>‘的表达式

不相容类型'id<MKAnnotation>‘的表达式
EN

Stack Overflow用户
提问于 2016-10-18 22:35:36
回答 1查看 180关注 0票数 0

我有一段代码

代码语言:javascript
复制
- (void)pinDropped {
StoreData *myStore = [StoreData sharedStore];

for (NSUInteger i = 0; i < annotations.count; i++) {

    MapViewController *ann = [[_mapView annotations] objectAtIndex:i];

    NSString *myStoreString = [NSString stringWithFormat:@"%@", myStore.myUebergabe];
    NSString *myAnnTitleString = [NSString stringWithFormat:@"%@", ann.title];


    if ([myStoreString isEqual:myAnnTitleString]) {
        [_mapView selectAnnotation:[_mapView.annotations objectAtIndex:i] animated:YES];

    }

}}

它在*ann的Xcode中创建此警告:

代码语言:javascript
复制
 Initializing 'MapViewController *__strong' with an expression of incompatible type 'id<MKAnnotation>'

我怎么摆脱这个警告?尽管有警告,一切都很好。

非常感谢你为我指明了正确的方向。马丁

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-18 22:40:33

改变这一点:

代码语言:javascript
复制
MapViewController *ann = [[_mapView annotations] objectAtIndex:i];

至:

代码语言:javascript
复制
id<MKAnnotation> ann = [[_mapView annotations] objectAtIndex:i];

因为[_mapView annotations]返回id<MKAnnotation数组,而不是MapViewController数组。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40119209

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档