-1

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 :)

4
  • Are you saying your column type is Array? As in when your creating it you name it Friends and select Array for its type? Commented Jan 30, 2015 at 3:13
  • Yes, Umm why was this question downvoted? Is it an invalid question? Commented 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? Commented Jan 30, 2015 at 5:29
  • Yes i want to load the whole array from a particular column into a local array. Commented Jan 31, 2015 at 16:16

2 Answers 2

0

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

Sign up to request clarification or add additional context in comments.

Comments

-1

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]);
        }
    }];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.