Pfquery…object to array.. to label

2019-03-04 10:12发布

it is my first time that I use parse and I'm a beginner.

I have built a table, and I show in the rows the data of my array

myArray= [NSMutableArray arrayWithObjects:@"Pasquale", @"Mario", nil];

cell.label1.text= [myArray objectAtIndex:indexPath.row];

Now I want to fetch the data from a class in parse and I wrote:

PFQuery *query = [PFQuery queryWithClassName:@"Dispositivi"];
[query whereKey:@"NomeDispositivo" equalTo:@"Franco"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error) {
// The find succeeded.
        NSLog(@"Successfully retrieved %d scores.", objects.count);
        // Do something with the found objects
for (PFObject *object in objects) {
            NSLog(@"%@", object.objectId);
}
    } else {
        // Log details of the failure
        NSLog(@"Error: %@ %@", error, [error userInfo]);
    }
}];

The code worked. But I want to know : How I can put the object in the array...and I can put a row in the array. For example every String of row: Name.

Thanks

1条回答
在下西门庆
2楼-- · 2019-03-04 10:48

If you want to append to the array:

[myArray addObjectsFromArray:objects];

*instead of your for loop. Note that this would currently result in your array containing NSString and PFObject instances and that could cause you issues...

Alternatively, replace the existing array:

myArray = [objects mutableCopy];
查看更多
登录 后发表回答