我在系统设置user
发布帖子(PFObject
)并发布到tableview控制器,所有其他用户都将该帖子发布到tableview。我希望能够抓住一个用户的帖子(PFObjects
)并能够在单独的tableview中显示它们,以便user
可以看到他们发布的内容。
这就是我发布PFObject的方式:
PFUser *user = [PFUser currentUser];
PFObject *quoteNew = [PFObject objectWithClassName:@"New"];
[quoteNew setObject:user forKey:@"author"];
[quoteNew setObject:[[self quoteText] text] forKey:@"quoteText"];
[quoteNew setObject:[[self attributionTitle] text] forKey:@"title"];
[quoteNew setObject:@"Story" forKey:@"cato"];
PFACL *postACL = [PFACL ACLWithUser:[PFUser currentUser]];
[postACL setPublicReadAccess:YES];
[quoteNew setACL:postACL];
这是我检索到表格视图的方式:
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
// Customize the table
// The className to query on
self.parseClassName = @"New";
// self.className2 = @"Story";
// The key of the PFObject to display in the label of the default cell style
self.textKey = @"title";
self.User = @"cato";
// self.textKey2 = @"title";
// Uncomment the following line to specify the key of a PFFile on the PFObject to display in the imageView of the default cell style
//self.imageKey = @"image";
// Whether the built-in pull-to-refresh is enabled
// self.pullToRefreshEnabled = YES;
// Whether the built-in pagination is enabled
self.paginationEnabled = YES;
// The number of objects to show per page
self.objectsPerPage = 100;
}
return self;
}
答案 0 :(得分:1)
您必须覆盖queryForTable方法以设置查询参数
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
[query whereKey:@"author" equalTo:@"name"]; //where you set the username to the specific user to get only this user's post.
// If no objects are loaded in memory, we look to the cache first to fill the table
// and then subsequently do a query against the network.
if (self.objects.count == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
[query orderByDescending:@"createdAt"];
return query;
}
在PFQueryTableViewController下查看https://www.parse.com/docs/ios_guide#ui-tables/iOS。