kAi*_*AiN 3 parse-platform pfquery
我在我的应用程序中使用Parse.com,我创建了一个"Post"类,在里面我有一个指针指定哪个用户发送了帖子.现在我在帖子的时间轴上看到了创建帖子的用户名的时间.由于用户是指针,我无法进行正确的查询,您知道如何解决此问题吗?
诀窍是使用PFQuery includeKeyParse自动填充相关指针数据.该user数据将不要求你做另一个查询它下载.
PFQuery *query = [PFQuery queryWithClassName:@"Post"];
// Include the user data with each post
[query includeKey:@"title_of_userpointer_column"];
[query findObjectsInBackgroundWithBlock:^(NSArray *postObjects, NSError *error)
{
if (!error) {
NSLog(@"Successfully retrieved: %d items", [postObjects count]);
// postObjects now contains the latest 100 Posts, and the "title_of_userpointer_column" field
// has been populated.
// For example:
for (PFObject * postObject in postObjects) {
// This does not require a network access.
PFObject *postAuthor = [postObject objectForKey:@"title_of_userpointer_column"];
NSLog(@"retrieved related Post Author: %@", postAuthor);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7951 次 |
| 最近记录: |