如何从PARSE.com中的PFquery获取NSArray中的objectId

时间:2014-04-12 11:20:56

标签: ios objective-c parse-platform pfquery

我的PFQuery返回以下说明。我正在尝试获取该类的objectId YouQuestions。例如:在下面的描述中,Ovx3B1TnaC是quesAray的第一个索引的objectId。但我不知道如何获取它。

Printing description of quesArray:
<__NSArrayM 0xe1198f0>(
<YouQuestions:OVx3BlTnaC:(null)> {
    askedUser = "<PFUser:XGvZsNyg9p>";
    attachedImage = "<PFFile: 0xb4c9d20>";
    category = Business;
    geoLocation = "<PFGeoPoint: 0xb4c9ea0>";
    question = "Who is kaka?";
    thumbImage = "<PFFile: 0xb4c9dd0>";
},

这就是我的做法但返回了

PFQuery *fetchTimeLine = [PFQuery queryWithClassName:@"YouQuestions"]; [fetchTimeLine whereKeyExists:@"objectId"]; [fetchTimeLine findObjectsInBackgroundWithBlock:^(NSArray *quesArray, NSError *error) { for (int i =0; i<quesArray.count; i++) { PFObject *obj = [quesArray[i] objectForKey:@"objectId"]; [searchobjectIDsArray addObject:obj.objectId]; } }];

修改

我像这样修理了

for (PFObject *object in quesArray) { NSLog(@"%@", object.objectId); }

1 个答案:

答案 0 :(得分:1)

获取id数组:

NSArray *oids = [quesArray valueForKeyPath:@"objectId"];