我的 JSON 响应有问题。由于某种原因,每次我运行程序时都会出现线程错误,也许它与错误有关..?我正在尝试获取 JSON 响应并根据 JSON 请求使用一组标记填充地图。
NSURLConnection
sendAsynchronousRequest:urlRequest
queue:queue
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if([data length] > 0 &&
error == nil){
NSData *jsonData = [NSData dataWithContentsOfURL:url];
if (jsonData != nil){
NSError *error = nil;
self.results = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
if(error == nil)
self.locations = _results;
for (NSDictionary *locations1 in self.locations){
CLLocationCoordinate2D annotationCoordinate =
CLLocationCoordinate2DMake([locations1[@"latitude"] doubleValue], [locations1[@"longitude"] doubleValue]);
Annotation *annotation2 = [[Annotation alloc] init];
annotation2.coordinate = annotationCoordinate;
annotation2.title = locations1[@"name"];
annotation2.subtitle = nil;
[self.mapView addAnnotation:annotation2];
**ERROR: sending 'Annotation *__strong' to parameter of incompatible type 'id<MKAnnotation>'
}
我不确定我的代表会出现什么问题?有任何想法吗?