Reputation: 1981
saveInBackgroundWithBlock stopped working after I upgraded parse library. Please check the code below, this used to work before but not anymore. Am I doing something wrong here?
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");
}
}];
}
}];
In log I am only getting
result: (
)
which is by NSLog(@"result: %@", result); but nothing from saveInBackgroundWithBlock
Upvotes: 1
Views: 106
Reputation:
Your problem is not with saveInBackgroundWithBlock but your query in findObjectsInBackgroundWithBlock is not fetching any result. Please run the same query on prase UI and check if your getting any result over there.
Upvotes: 1