当前位置: 动力学知识库 > 问答 > 编程问答 >

xcode - One-to-Many: How to get the same blog posts to show up for every user?

问题描述:

I was about to get One-to-Many up an running in no time. I signed into my app as a dummy user named "diva" and made posts that were successfully added to parse.com with no hassle. However, when I log out from the user account "diva," none of the posts show up anymore. I figured it was because of this code:

PFQuery *postQuery = [PFQuery queryWithClassName:@"Post"];

[postQuery orderByDescending:@"createdAt"];

[postQuery whereKey:@"author" equalTo:[PFUser currentUser]];

Which makes sense because "currentUser" is no longer "diva." My question is how do I get the same blog posts to show up for every user as opposed to just the currentUser? How do I call the object ID for just one user?

I have tried:

[postQuery whereKey:@"author" equalTo:@"diva"];

but that didn't work. I have also tried:

[postQuery whereKey:@"author" equalTo:@"fu8CDOLeKu"];

"fu8CDOLeKu" being the object ID for the user "diva," that still doesn't work. What now?

网友答案:

Try this:

NSString *userId ="fu8CDOLeKu";
[postQuery whereKey:@"author" equalTo:[PFObject objectWithoutDataWithClassName:@"_User" objectId:userId]
分享给朋友:
您可能感兴趣的文章:
随机阅读: