Parse.com saveInBackgroundWithBlock根本没有被调用

时间:2015-03-03 13:08:41

标签: parse-platform

升级解析库后,

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

1 个答案:

答案 0 :(得分:1)

您的问题不在于saveInBackgroundWithBlock,但您在findObjectsInBackgroundWithBlock中的查询未获取任何结果。请在prase UI上运行相同的查询,并检查您是否在那里获得任何结果。