Objective c 我有两个问题吗?
由于PFFile只能通过GetDataInBackgroundithBlock检索,因为它们不是对象(我想..),所以在进行查询后,我调用GetDataInBackgroundithBlock将PFFile转换为UIImage 我是否通过调用FindObjectInBackgroundithBlock和GetDataBackgroundithBlock来进行两个查询?如果是这样的话,有没有办法只通过一个查询就完成这项工作Objective c 我有两个问题吗?,objective-c,parse-platform,pfquery,Objective C,Parse Platform,Pfquery,由于PFFile只能通过GetDataInBackgroundithBlock检索,因为它们不是对象(我想..),所以在进行查询后,我调用GetDataInBackgroundithBlock将PFFile转换为UIImage 我是否通过调用FindObjectInBackgroundithBlock和GetDataBackgroundithBlock来进行两个查询?如果是这样的话,有没有办法只通过一个查询就完成这项工作 PFQuery *query = [PFQuery queryWithCl
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];
}}];
}
}];
您正在发出两个异步网络请求,但其中只有一个请求——findObjects——是查询。find返回一个指向文件的对象,为了获取文件的内容,需要第二个(非查询)请求 有一种方法可以处理来自客户端的单个请求:一个云函数,它执行与发布的代码基本相同的操作,然后返回检索到的数据