Ios 如何在现有解析对象上重新加载关系

Ios 如何在现有解析对象上重新加载关系,ios,parse-platform,Ios,Parse Platform,我在一个数组中有一堆来自PFFetch的对象。这些对象具有指向其他对象的链接(指针数组指针)。为了限制为初始获取发送的数据量,我不想在获取时使用includeKey下载所有链接对象 稍后,我有了这些对象的一个子集,我确实希望获取相关对象和这些对象的关系。如果我再次获取它们,我会复制我的应用程序中的对象(并且可能不必要地通过我已经在应用程序中的线路发送对象) 也就是说,我希望原始数组中的一些对象显示为原始获取具有: [query includeKey:@"relationship"]; [quer

我在一个数组中有一堆来自PFFetch的对象。这些对象具有指向其他对象的链接(指针数组指针)。为了限制为初始获取发送的数据量,我不想在获取时使用includeKey下载所有链接对象

稍后,我有了这些对象的一个子集,我确实希望获取相关对象和这些对象的关系。如果我再次获取它们,我会复制我的应用程序中的对象(并且可能不必要地通过我已经在应用程序中的线路发送对象)

也就是说,我希望原始数组中的一些对象显示为原始获取具有:

[query includeKey:@"relationship"];
[query includeKey@"relationship.secondRelationship"];
设置原始密钥。最好的方法是什么?我曾想象过PFObject上的一些API,如:

+(void) fetchIfNeededInBackground:(NSArray*)objects includeKey:(NSString*)key block:...


但是我找不到这样的东西。

你可能在寻找著名的查询中包含的

下面是一个使用containedIn解决著名问题“match friends from FB”的示例


我希望有帮助

谢谢。目前,我通过在初始查询中积极使用includeKey:解决了这个问题。当我回来进行优化时,我一定会尝试这个。我在想。。。。。。。。。。我怀疑会有什么问题,只是总是“包括钥匙”。。。我的意思是,即使是1000条记录,数据量也很小。我知道,即使“包含”只用于1000个结果中的一小部分,我们也从来没有烦恼过“延迟包含”。也许这不是什么大问题……通常“containedIn”非常有用(如示例所示)
- (void)includeKeyAtNextFetch:(NSString*)key
+(void)findFBFriendsWhoAreOnSkywall
{
// issue a fb graph api request to get the fbFriend list...

[APP huddie];

[FBRequestConnection
 startForMyFriendsWithCompletionHandler:^(
  FBRequestConnection *connection, id result, NSError *error)
  {
  if (!error)
   {
   // here, the result will contain an array of the user's
   // FB friends, with, the facebook-id in the "data" key

   NSArray *fbfriendObjects = [result objectForKey:@"data"];

   int kountFBFriends = fbfriendObjects.count;

   NSLog(@"myfriends result; count: %d", kountFBFriends);

   // NOW MAKE A SIMPLE ARRAY of the fbId of the friends
   // NOW MAKE A SIMPLE ARRAY of the fbId of the friends
   // NOW MAKE A SIMPLE ARRAY of the fbId of the friends

   NSMutableArray *fbfriendIds =
    [NSMutableArray arrayWithCapacity:kountFBFriends];
   for (NSDictionary *onFBFriendObject in fbfriendObjects)
    [fbfriendIds addObject:[onFBFriendObject objectForKey:@"id"]];

   for (NSString *onef in fbfriendIds)
      NSLog(@"and here they are .. %@", onef);

   // query to find friends whose facebook ids are in that list:
   // USE THAT SIMPLE ARRAY WITH THE MAGIC 'containedIn' call...

   // amazingly easy using the ever-loved containedIn:
   // amazingly easy using the ever-loved containedIn:
   // amazingly easy using the ever-loved containedIn:

   PFQuery *SWUSERSTOADDASFRIENDS = [PFUser query];
   [SWUSERSTOADDASFRIENDS whereKey:@"fbId" containedIn:fbfriendIds];
   [SWUSERSTOADDASFRIENDS findObjectsInBackgroundWithBlock:^
    (NSArray *objects, NSError *error)
    {
    if (error) // problem getting the matching-friends list
     {
     [PFAnalytics .. it al went to hell.];
     NSLog(@"disaster at the last step!  but that's ok");

     [APP.hud hide:YES];
     [backTo literallyGoToMainPage];
     }
    else
     {
     // so all the people in OBJECTS, now make them in to SW friends.

     [PFAnalytics trackEvent:@"FBMatchDone" ...];
     NSLog(@"found this many fb matches ... %d", objects.count);
     [FBMatch actuallyMakeThemFriends:objects];
     [APP.hud hide:YES];
     [FBMatch message .. objects.count showTheseNames:objects];
     }
    }];
   }
  else // problem getting the friend list....
   {
   [PFAnalytics .. problem];

   [APP.hud hide:YES];
   [backTo literallyGoToMainPage];
   }
  }];
}