Parse.com 根本没有调用 saveInBackgroundWithBlock
Parse.com saveInBackgroundWithBlock not getting called at all
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(@"result: %@", 结果);但没有来自 saveInBackgroundWithBlock
您的问题不在于 saveInBackgroundWithBlock,而是您在 findObjectsInBackgroundWithBlock 中的查询未获取任何结果。请 运行 在 prase UI 上进行相同的查询,并检查你是否在那边得到任何结果。
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(@"result: %@", 结果);但没有来自 saveInBackgroundWithBlock
您的问题不在于 saveInBackgroundWithBlock,而是您在 findObjectsInBackgroundWithBlock 中的查询未获取任何结果。请 运行 在 prase UI 上进行相同的查询,并检查你是否在那边得到任何结果。