Parse.com - 获取包含在 [PFUser currentUser] 中的指针数据 [英] Parse.com - Getting pointer data contained in [PFUser currentUser]
问题描述
我使用的是 Parse.com iOS SDK,我不知道我需要调用什么方法来确保 PFUser currentUser 包含其中包含的每个指针的数据.可能很简单,但是,作为这个平台的初学者,我找不到解决方案.
I am using the Parse.com iOS SDK, and I don't know what method I need to call to make sure that the PFUser currentUser contains the data for each pointer contained in it. It is probably very simple, but, as a beginner with this platform, I cannot find a solution.
只是为了澄清,我试图在下面获取用户名项.看起来它总是为空,即使我在继续之前调用 [[PFUser currentUser] fetchIfNeeded]
:
Just to clarify, I am trying to get the username item in the following. It looks like it is always null, even though I am calling [[PFUser currentUser] fetchIfNeeded]
before proceeding:
[[[PFUser currentUser] objectForKey:@"partner"] objectForKey:@"username"];
谢谢,
安德里亚
推荐答案
您可以使用 includeKey:
PFQuery *query = [PFUser query];
[query includeKey:@"partner"];
[query includeKey:@"anotherPointerColumnName"];
[query getObjectInBackgroundWithId:[[PFUser currentUser] objectId]
block:^(PFObject *populatedUser, NSError *error) {
PFObject *partner = populatedUser[@"partner"];
PFObject *another = populatedUser[@"anotherPointerColumnName"];
}];
你也可以使用更深的层次,所以如果 partner
包含一个指针,你需要调用 deeperPointerColumnName
:
You can also use deeper levels, so if partner
contained a pointer in it you needed called deeperPointerColumnName
:
[query includeKey:@"partner.deeperPointerColumnName"];
然后在您的完成块中,您可以在获得合作伙伴后阅读:
Then in your completion block you can read it after you get the partner:
PFObject *partner = populatedUser[@"partner"];
PFObject *deeper = partner[@"deeperPointerColumnName"];
这篇关于Parse.com - 获取包含在 [PFUser currentUser] 中的指针数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!