我对 iOS 很陌生PFQuery
,我需要你的帮助
我试图将获得的对象数组存储PFQuery
到本地NSArray
,我试图在里面做,if (!error)
但它不会离开块,一旦块终止,我的数组上的值也是如此。
//InstallersDirectory.m
@interface InstallersDirectoryTVC ()
@property (nonatomic, strong) NSArray *supervisors;
@end
//more code goes here
- (void)viewDidLoad
{
[super viewDidLoad];
PFQuery *query = [PFQuery queryWithClassName:@"InstallersInfo"];
[query whereKey:@"supervisor" equalTo:@"yes"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
self.supervisors = [objects valueForKey:@"supervisor"];
}
}else {
NSLog(@"Error, %@ %@",error,[error userInfo]);
}
}];
一切都在块内工作,例如 self.supervisors.count 或NSLog
,但它根本不会离开块。你能告诉我如何才能将这些值存储到 self.supervisors 吗?
谢谢 !!
编辑 | 评论