【发布时间】:2014-03-19 03:31:22
【问题描述】:
我已经下载了这个Raywenderlich tutorial,但我对这部分代码有疑问。
我还是 iOS 开发的新手,我不明白这意味着什么。我在互联网上搜索过,但没有一个是答案。
请帮帮我。
int index = [_locations indexOfObjectPassingTest:^(id obj, NSUInteger index, BOOL *stop) {
return [[obj location] isEqual:location];
}];
有3个错误如下:
发现多个名为“location”的方法的结果、参数类型或属性不匹配
不兼容的块指针类型将'void (^)(__strong id, NSUInteger, BOOL *)'发送到'BOOL (^)(__strong id, NSUInteger, BOOL *)'类型的参数
错误的接收器类型“CGFloat”(又名“float”)
这是完整的代码,您可以在其中找到这一行:
- (void)didTouchMarkerView:(MarkerView *)markerView
{
ARGeoCoordinate *tappedCoordinate = [markerView coordinate];
CLLocation *location = [tappedCoordinate geoLocation];
int index = [_locations indexOfObjectPassingTest:^(id obj, NSUInteger index, BOOL *stop) {
return [[obj location] isEqual:location];
}];
if(index != NSNotFound)
{
Place *tappedPlace = [_locations objectAtIndex:index];
[[PlacesLoader sharedInstance] loadDetailInformation:tappedPlace successHanlder:^(NSDictionary *response) {
NSLog(@"Response: %@", response);
NSDictionary *resultDict = [response objectForKey:@"result"];
[tappedPlace setPhoneNumber:[resultDict objectForKey:kPhoneKey]];
[tappedPlace setWebsite:[resultDict objectForKey:kWebsiteKey]];
[self showInfoViewForPlace:tappedPlace];
} errorHandler:^(NSError *error) {
NSLog(@"Error: %@", error);}];
}
}
【问题讨论】:
标签: ios iphone location augmented-reality semantics