1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| __block NSString *longitude; // __block,静态变量 [self.manager POST:URL parameters:params success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { NSDictionary *locDictionary = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil]; longitude = [locDictionary objectForKey:@"lon"]; // 纠正后经度 if (finishBlock) { finishBlock(longitude, nil); } } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { NSLog(@"%@", error); if (finishBlock) { finishBlock(nil, error); } }];
|