根据解析API文档,"其他对象的安全性"。
创建一个只能由当前用户访问的私人笔记:
PFObject *privateNote = [PFObject objectWithClassName:@"Note"];
privateNote[@"content"] = @"This note is private!";
privateNote.ACL = [PFACL ACLWithUser:[PFUser currentUser]];
[privateNote saveInBackground];
链接:https://www.parse.com/docs/ios_guide#users-acls/iOS
然后,只有当前用户才能访问此注释,但该用户登录的任何设备都可以访问该注释。
问题:如何检索我的所有私人笔记?无法在文档中找到。
答案 0 :(得分:3)
您在注释类中添加了一个名为" user"它会在你的表中创建用户指针。
PFObject *privateNote = [PFObject objectWithClassName:@"Note"];
privateNote[@"content"] = @"This note is private!";
privateNote[@"user"] = [PFUser currentUser];
privateNote.ACL = [PFACL ACLWithUser:[PFUser currentUser]];
[privateNote saveInBackground];
当您想要检索与该用户相关的所有笔记时,您可以使用以下代码
PFQuery *query = [PFQuery queryWithClassName:@"Note"];
[query whereKey:@"user" equalTo:[PFUser currentUser]];
NSArray *usersNote = [query findObjects];
NSLog(@"%@",usersNote);
在上面的数组你可以得到记录。
希望这会对你有所帮助。
答案 1 :(得分:1)
实际上我还有另一个简单的解决方案:
无需创建额外的列。你可以简单地使用它:
PFObject *privateNote = [PFObject objectWithClassName:@"Note"];
privateNote[@"content"] = @"This note is private!";
privateNote.ACL = [PFACL ACLWithUser:[PFUser currentUser]];
[privateNote saveInBackground];
PFQuery *query = [PFQuery queryWithClassName:@"Note"];
NSArray *usersNote = [query findObjects];
NSLog(@"%@",usersNote);
它会自动检索私信。