我正在iOS上使用Parse.com
服务作为我的云。
我目前的任务是尝试从Facebook检索好友列表,然后保存该列表以解析云。
我可以使用parse.com的示例/教程来PFObject
保存单个PFObject
,但是当我尝试保存我的对象列表时,它不起作用。
那么你能解释一下我的原因,以及在我的案例中哪个是解决方案?
我的代码:
for (NSDictionary<FBGraphUser>* friend_ in friends) {
NSLog(@"I have a friend named %@ with id %@", friend_.name, friend_.id);
PFObject *gameScore = [PFObject objectWithClassName:@"GameScore"];
NSLog(@"Add ID");
gameScore[@"id"] = friend_.id;
NSLog(@"Name");
gameScore[@"name"] = friend_.name;
NSLog(@"Birthday");
gameScore[@"birthday"] = friend_.birthday;
[gameScore saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
NSLog(@"Sample sending completed");
}
}];
}
答案 0 :(得分:0)
在使用多个请求在Parse中保存多个对象时,我也遇到过这个问题。您应该尝试以下请求,该请求允许您使用单个请求保存PFObject *数组:
+ (void)saveAllInBackground:(NSArray *)objects block:(PFBooleanResultBlock)block
答案 1 :(得分:0)
PFObject *gameScore = [PFObject objectWithClassName:@"GameScore”];
[gameScore setObject:[NSNumber numberWithInt:1337] forKey:@"score"];
[gameScore setObject:@"Sean Plott" forKey:@"playerName"];
[gameScore setObject:[NSNumber numberWithBool:NO] forKey:@"cheatMode"];
[gameScore save];