How to get the objectId from NSArray from PFquery in PARSE.com
-
21-12-2019 - |
Question
My PFQuery returns the following description.I am trying to fetch the objectId of the class
YouQuestions
.For eg: in the below description Ovx3B1TnaC
is the objectId for the first index of quesAray. But I have no idea on how to fetch it.
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>";
},
This is how I did but returned nil
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];
}
}];
EDIT:
I fixed it like this
for (PFObject *object in quesArray) {
NSLog(@"%@", object.objectId);
}
Solution
to get the array of ids:
NSArray *oids = [quesArray valueForKeyPath:@"objectId"];