我有一段代码
- (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中创建此警告:
Initializing 'MapViewController *__strong' with an expression of incompatible type 'id<MKAnnotation>'我怎么摆脱这个警告?尽管有警告,一切都很好。
非常感谢你为我指明了正确的方向。马丁
发布于 2016-10-18 22:40:33
改变这一点:
MapViewController *ann = [[_mapView annotations] objectAtIndex:i];至:
id<MKAnnotation> ann = [[_mapView annotations] objectAtIndex:i];因为[_mapView annotations]返回id<MKAnnotation数组,而不是MapViewController数组。
https://stackoverflow.com/questions/40119209
复制相似问题