I am trying to display data from a parse table. The class name is Account
and the column I want to retrieve data from is called name
. I keep getting an error of property name not found on object of type NSArray
. I understand that you cannot pass a NSArray
to an NSString
but how do i display this data correctly. Any help would be great.
Here is my code that does not work:
- (void)viewDidLoad
{
[super viewDidLoad];
PFQuery *query = [PFQuery queryWithClassName:@"Account"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
self.test.text = objects.name;
}];
}
Here is what you want to do (this is just going to display 'name' for the first object in the array):
PFQuery *query = [PFQuery queryWithClassName:@"Account"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
self.test.text = [[objects objectAtIndex:0] objectForKey:@"name"];
}];