0

I currently have this query for parse.com:

- (void)viewDidLoad
{
    PFQuery *activityQuery = [PFQuery queryWithClassName:@"Activities"];


    [activityQuery whereKey:@"triathlete" equalTo:[PFUser currentUser]];

    [activityQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
            _activityArray = objects;
            NSLog(@"activityArray = %@",_activityArray);

        }
    }];

And it stores all of the data from each each object in my database. My question is how can I get the data from the individual columns rather than everything in one array.

Many Thanks

1
  • Can you please explain how you would like the data? With this query, you will get an array with all the activities the current user has performed. What would you prefer? Commented Mar 8, 2014 at 14:24

2 Answers 2

1

If I understand your question correctly, you can separate columns in different arrays, inside your block, like this:

[activityQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
            NSMutableArray *column1 = [objects valueForKey:@"column1"];
            NSMutableArray *column2 = [objects valueForKey:@"column2"];
            NSMutableArray *column3 = [objects valueForKey:@"column3"];
        }
    }];

Then do whatever you need to do with each Array.

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

Comments

0

to get the individual columns from the query result use the following manner

    [activityQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
(if!error){   
 for(PFObject *object in objects){
        // to print individual object one by one
    NSLog(@"%@",object);
    // to retrieve individual column  if the column is string type
    NSLog(@"%@",[object objectForkey:@"yourColumnName"]);

    }
}];

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.