I am learning Parse and stuck on querying array values.
I have gone through this and this but I'm still now able to get it working.
I have a parse class called User, and a column called "Friends".
This column has an Array value. Now how can I load this array into my local NSArray?
Any help will be appreciated,
Thanks :)
-
Are you saying your column type is Array? As in when your creating it you name it Friends and select Array for its type?soulshined– soulshined2015-01-30 03:13:18 +00:00Commented Jan 30, 2015 at 3:13
-
Yes, Umm why was this question downvoted? Is it an invalid question?votelessbubble– votelessbubble2015-01-30 04:53:56 +00:00Commented Jan 30, 2015 at 4:53
-
@MärmîkŠhâh Do you want to load all the contents of all the arrays in your User class into an NSArray? Or do you want to just load an array contained in your PFUser currentUser's column, for example?Lyndsey Scott– Lyndsey Scott2015-01-30 05:29:35 +00:00Commented Jan 30, 2015 at 5:29
-
Yes i want to load the whole array from a particular column into a local array.votelessbubble– votelessbubble2015-01-31 16:16:34 +00:00Commented Jan 31, 2015 at 16:16
Add a comment
|
2 Answers
The issue is because you have defined your column to hold arrays in each row as opposed to one value for each row where the column entirely would be an array.
Instead of creating a new column with Array type, delete the Friends column you have and re-create it, except this time, instead of choosing Array as the column type select 'String' then follow the same posts that you put in your question to retrieve the objects or follow the Parse Docs under the 'Basic Queries' section
Comments
Try the following:
PFQuery *query = [PFQuery queryWithClassName:@"_User"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
NSLog("%@", object[@"Friends"]);
}
}else {
NSLog(@"Error, %@ %@",error,[error userInfo]);
}
}];