2015-03-03 41 views
1

saveInBackgroundWithBlock在升级解析库后停止工作。请检查下面的代码,这用于之前的工作,但不再。我在这里做错了什么?Parse.com 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

你的问题不是saveInBackgroundWithBlock,而是你在findObjectsInBackgroundWithBlock中的查询没有获取任何结果。请在Prase UI上运行相同的查询,并检查您是否在那里获得任何结果。