jacobsieradzki
jacobsieradzki

Reputation: 1108

Download one array from Parse

Quite a simple question really but can't find the answer anywhere.

On the Parse data browser, there are lots of users and they each have an array with a bunch of string values, how do i download just one of these arrays from just one user into an NSArray of string values?

Thanks in advance.

Upvotes: 0

Views: 83

Answers (1)

danh
danh

Reputation: 62676

Do you know the objectId of the user? or the username? Say it's the username:

PFQuery *query = [PFQuery queryWithClassName:@"User"];
[query whereKey:@"username" equalTo:@"Vladimir Putin"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error) {
        if (objects.count) {
            PFUser *vladimir = objects[0];
            NSLog(@"Putins strings are %@" [vladimir objectForKey:@"theArrayColumn"]);
        } else {
            // where are you Vlad?
        }
    } else {
        NSLog(@"Error: %@ %@", error, [error userInfo]);
    }
}];

It's easier if you know the object id. Then use getObjectInBackgroundWithId: instead of find. (To be clear, you'll be downloading the object and it's array property. There's no way that I know of to get just a property).

Upvotes: 2

Related Questions