从NSDictionary访问PFUser

时间:2015-12-04 03:17:12

标签: ios objective-c iphone forms parse-platform

我正在尝试检索NSDictionary中的PFUser,但是当我运行代码时,我无法检索任何数据。提供的字典中的PFUser是用户密钥。这是我的输出:

// My dictionary
{
    hours = "10 Hours";
    location = j;
    notes = h;
    title = j;
    user = "<PFUser: 0x7fea4d578d90, objectId: h1WOITDkrF, localId: (null)> {\n    email = \"XXXXX@yahoo.com\";\n    fullName = Pradyumn;\n    username = Prnk281;\n }";
}

// Should be displaying the PFUser objectId displays null
2015-12-03 22:11:24.774 XXXXX[16176:816409] User ID: (null)

这是我尝试从PFUser中检索objectId的代码,

-(void)savePressed:(UIBarButtonItem * __unused)button
{
    NSArray * validationErrors = [self formValidationErrors];
    if (validationErrors.count > 0){
        [self showFormValidationError:[validationErrors firstObject]];
        return;
    }
    NSLog(@"FormValues: %@",self.formValues);
    PFUser *selectedUser = [self.formValues objectForKey:@"user"];
    NSLog(@"User ID: %@", [selectedUser objectForKey:@"objectId"]);
    [self.tableView endEditing:YES];
}

2 个答案:

答案 0 :(得分:0)

当您进行查询以获取此数据时,只需在查询中添加一行。

[query includeKey:@"YOUR COLUMN NAME"];

您将获得当前词典中用户的所有详细信息。

答案 1 :(得分:0)

我设法通过遵循两个给出的评论来解决我的答案。

首先,我检查了我的selectedUser是否为可用值,它是:

NSLog(@"Selected user : %@",selectedUser);

然后我做了@ paulw11所说的并使用了selectedUser.objectId