Поскольку PFFiles можно получить только через getDataInBackgroundWithBlock, потому что они не объекты (я думаю ..) после выполнения запроса, я вызываю getDataInBackgroundWithBlock для преобразования PFFile в UIImage.Я делаю два вопроса?
Я делаю два запроса, вызывая findObjectInBackgroundWithBlock, а затем getDataBackgroundWithBlock? Если да, можно ли это сделать только с одним запросом?
PFQuery *query = [PFQuery queryWithClassName:@"photoObject"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error){
for (id object in objects) {
PFFile *imageFile = object[@"photo"];
[imageFile getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) {
if (!error) {
[self.annotationArray addObject:object[@"location"]];
NSLog(@"Annotation's coordinate : %@", self.annotationArray);
self.callOutImage = [UIImage imageWithData:imageData];
self.geoPoint = object[@"location"];
CLLocationCoordinate2D locCoord = CLLocationCoordinate2DMake(self.geoPoint.latitude, self.geoPoint.longitude);
CustomPin *pin = [[CustomPin alloc] initWithTitle:[object objectId] location:locCoord image:self.callOutImage];
[self.mainMap addAnnotation:pin];
}}];
}
}];