以下是要解释的图片;
用户1根据[PFUser currentUser] .username;
登录并查看以下内容但是,如果我注册一个新帐户并以用户2身份登录,则共享相同的数据,并根据[PFUser currentUser]更改名称。用户名;
我确定有一种方法,但我不确定如何确保在登录并保护PFUser ID后更改任何PFObject只会与该用户相关联?
答案 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];
}
}];
}