parse-platform - 在 Parse.com 中使用指针用户查询

标签 parse-platform pfquery

我在我的应用程序中使用 Parse.com,我创建了一个“帖子”类,在里面我有一个指针,它指定哪个用户发送了帖子。现在我在帖子的时间线上看到了创建帖子的用户名的时间。由于用户是指针,我无法正确查询,您知道我该如何解决这个问题吗?

最佳答案

诀窍是使用 PFQuery includeKey 让 Parse 自动填充相关的指针数据。 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);
         }
 }

关于parse-platform - 在 Parse.com 中使用指针用户查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19099137/

相关文章:

swift - ParseLiveQuery 无法访问 Pointer 对象

ios - 解析单个字符串字段的查询,其中值与数组中提供的任何字符串匹配

Javascript promise 链接在 Loop 内

backbone.js - 使用 Promises 解析云代码的多个查询

ios - 解析 + Swift + 匿名

dart - JS Interop编译为javascript时出现问题

android - 无法在 Trigger.io Android 应用程序上启动接收器 com.parse.ParseBroadcastReceiver

swift - 如何使用 NSComparator 组织解析查询? swift

ios - PFQuery findObjectsInBackgroundWithBlock 不返回

arrays - 按 SWIFT 顺序从数组中进行 PFQuery