PFUsers正在共享所有相同的PFObject?

时间:2017-08-25 04:35:15

标签: ios objective-c parse-platform pfobject pfuser

以下是要解释的图片;

用户1根据[PFUser currentUser] .username;

登录并查看以下内容

enter image description here enter image description here

但是,如果我注册一个新帐户并以用户2身份登录,则共享相同的数据,并根据[PFUser currentUser]更改名称。用户名;

enter image description here enter image description here

我确定有一种方法,但我不确定如何确保在登录并保护PFUser ID后更改任何PFObject只会与该用户相关联?

2 个答案:

答案 0 :(得分:1)

它按预期工作。您应该将图像与上载它的用户一起存储。标签Uploaded by: *username*应使用"Uploaded by: " + photoUploader.username而不是"Uploaded by: " + PFUser.currentUser.username

构建

答案 1 :(得分:0)

我可以通过添加[query whereKey:@"user" equalTo:[PFUser currentUser]];

来修复它
-(void)getReportImages{
//Fetch images
PFQuery *query = [PFQuery queryWithClassName:@"ReportImageObject"];

[query orderByDescending:KEY_CREATION_DATE];
[query whereKey:@"user" equalTo:[PFUser currentUser]];
[query findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {
    if (!error) {
        self.reportsObjectArray = nil;
        self.reportsObjectArray = [[NSArray alloc] initWithArray:objects];
        [self loadReportViews];
    } else {
        [self showErrorView:error];
    }
}];
}