2014-07-02 21 views
0

保存用户造成错误:没有找到对象的更新(代码:101,版本:1.2.19)保存用户的原因没有找到对象错误

[PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) { 
     if (!error) { 
      [PFUser currentUser].location = geoPoint; 
      [[PFUser currentUser] save]; 
     } 
    }]; 

我究竟做错了什么?

HTTP POST请求https://api.parse.com/2/update

{ 
    "iid": "[redacted]", 
    "classname": "_User", 
    "data": { 
     "email": "[email protected]", 
     "objectId": "[redacted]" 
    }, 
    "session_token": "[redacted]", 
    "v": "i1.2.19", 
    "uuid": "[redacted]" 
} 

响应

{ 
    "code": 101, 
    "error": "object not found for update" 
} 

回答

1

我有同样的问题,因为你,我做了一些测试,找出根本原因:

  • 创建新类GameScore作为document
  • 做同样的创建和更新对象,并查找它运作良好
  • 检查“ACL”列并与您的问题数据进行比较。看到?

Works ACL, I done modify for * to make it clear
工程ACL,我做了修改*要清楚

enter image description here
失败ACL。

正如你可以看到写权限锁定用户“6iIv5XWZvM”,这就是为什么你的更新将“找不到对象”

您可以直接更改数据记录为“*”,让你更新效果很好。

好的!这里是解决方案如下:

  1. 更改每个记录 “ACL” 数据栏如下:

    { “*”:{ “写”:真实的, “读”:真正}}

  2. 您需要登录PFUSer作为特定用户才能将ACL更改为公开。对于我的情况使用objectId将是“6iIv5XWZvM”。我需要设置密码和登录信息并使用代码来登录和修改它。详细iOS的代码如下:

    //iOS Sample 
    [PFUser logInWithUsernameInBackground:@"USERNAME" password:@"PASSWORD" block:^(PFUser *user, NSError *error) { 
        if (user) { 
         PFQuery *query = [PFQuery queryWithClassName:CLASS_NAME]; 
         [query findObjectsInBackgroundWithBlock:^(NSArray *objs, NSError *error) { 
          for (PFObject *obj in objs) { 
           PFACL *defaultACL = [PFACL ACL]; 
           [defaultACL setPublicReadAccess:YES]; 
           [defaultACL setPublicWriteAccess:YES]; 
           [obj setACL:defaultACL]; 
           [obj saveInBackground]; 
          } 
         }]; 
        } else { 
         // The login failed. Check error to see why. 
         } 
    }]; 
    

但是记得添加下面的设置保存新数据之前,如果你不希望再发生了(注:这将是安全问题)

//It is iOS code sample. 
PFACL *defaultACL = [PFACL ACL]; 
[defaultACL setPublicReadAccess:YES]; 
[defaultACL setPublicWriteAccess:YES]; 
[PFACL setDefaultACL:defaultACL withAccessForCurrentUser:YES]; 
0

试试这个,我用这个,当我需要保存的对象为当前用户。希望它会有所帮助。

 PFUser *user = [PFUser currentUser]; 
     [user setObject:geoPoint forKey:@"location"]; 

     [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { 
      if (error){ 
       NSLog(@"Error %@ %@", error, [error userInfo]); 
      } 
     }]; 
+0

获得与保存在背景方法中一样的错误。 – MonkeyBonkey

0

错误:“尝试对保存用户没有访问ACL的对象”时,找不到更新对象“。

为了让用户改变你需要设置PFACL许可对象时创建对象:

对于一个特定的用户:

PFObject *object = /*the object you want to save*/ 
NSString *userID = /*the objectID of the user you want to let perform modifications later*/ 
PFACL *groupACL = [PFACL ACL]; 
[groupACL setWriteAccess:YES forUserId:userID]; 
object.ACL = groupACL; 

对于所有用户:

PFObject *object = /*the object you want to save*/ 
NSString *userID = /*the objectID of the user you want to let perform modifications later*/ 
PFACL *groupACL = [PFACL ACL]; 
[groupACL setPublicWriteAccess:YES]; 
object.ACL = groupACL; 
相关问题