saveInBackgroundWithBlock停止工作。请检查下面的代码,这用于以前的工作,但不再是。我在这里做错了吗?
PFQuery* query = [PFQuery queryWithClassName: @"FoodDaily"];
[query whereKey: @"user_id" equalTo: [[PFUser currentUser] objectId]];
[query whereKey: @"date" equalTo: [dicItem valueForKey: @"date"]];
m_loadingView.hidden = NO;
[query findObjectsInBackgroundWithBlock:^(NSArray *result, NSError *error)
{
if(error)
{
NSLog(@"error");
m_loadingView.hidden = YES;
[[AppDelegate getDelegate] showMessage: NETWORK_DISCONNECT_ERROR];
return;
}
if (!error) {
NSLog(@"result: %@", result);
m_loadingView.hidden = YES;
PFObject* objRecord = [PFObject objectWithClassName:@"FoodDaily"];
if ([result count]>0) {
objRecord = [result objectAtIndex: 0];
}
[objRecord setObject: [dicItem valueForKey: @"breakfast_food"] forKey: @"breakfast_food"];
m_loadingView.hidden = NO;
[objRecord saveInBackgroundWithBlock: ^(BOOL succeeded, NSError* error)
{
if(succeeded)
{
m_loadingView.hidden = YES;
NSLog(@"Success Updating New Food Daily Item");
[self.navigationController popToViewController: [AppDelegate getDelegate].m_viewFoodDaily animated: YES];
}
else
{
m_loadingView.hidden = YES;
[[AppDelegate getDelegate] showMessage: NETWORK_DISCONNECT_ERROR];
NSLog(@"Failed Saving New Food Item");
}
}];
}
}];
在日志中我只是
result: (
)
由NSLog(@"结果:%@",结果);但没有来自saveInBackgroundWithBlock
答案 0 :(得分:1)
您的问题不在于saveInBackgroundWithBlock,但您在findObjectsInBackgroundWithBlock中的查询未获取任何结果。请在prase UI上运行相同的查询,并检查您是否在那里获得任何结果。