2013-05-05 22 views
0

我是Parse中的newbiew。我正在嘗試瞭解以下鏈接。 https://www.parse.com/docs/ios_guide#objects-updating/iOS類中的iOS-Parse更新行

以下是更新的代碼無法工作並創建一個新的代碼。這是我的代碼;

PFObject *testObject = [PFObject objectWithClassName:@"TestObject"]; 
      [testObject setObject:@"oldtestobject" forKey:@"testkey"]; 
      [testObject save]; 

我只想更新oldtestobject字符串。獲得新測試的新價值。

對不起,我的英語不好。我希望我在說什麼。

回答

2

如果要使用解析更新對象,首先需要創建一個PFQuery以獲取要更新的對象,然後修改數據,然後保存新版本。以下是示例代碼的樣子:

// Create the PFQuery 
PFQuery *query = [PFQuery queryWithClassName:@"TestObject"]; 

// Retrieve the object by id 
[query getObjectInBackgroundWithId:@"oldTestObjectID" block:^(PFObject *pfObject, NSError *error) { 

    // Now let's update it with some new data. In this case, only cheatMode and score 
    // will get sent to the cloud. playerName hasn't changed. 
    [pfObject setObject:@"rowData" forKey:@"columnName"]; 
    [pfObject saveInBackground]; 
}]; 
+0

但是,如何獲得ObjectID才能執行查詢? – Supertecnoboff 2015-12-22 14:40:37