As Firebase doesn't guarantee order when reading from a base, we can get unordered output from this async call:
-(void)loadDataFromFirebase
{
handles = [[NSMutableArray alloc] init];
Firebase* listRef = [[Firebase alloc] initWithUrl:@"https://mobilefeast.firebaseIO.com/foodtrucks"];
[listRef observeEventType:FEventTypeChildAdded withBlock:^(FDataSnapshot *snapshot) {
NSLog(@"%@", snapshot.name);
[handles addObject:snapshot.value];
[self.handleTableView reloadData];
}];
}
In the example ordered reading snippet from Firebase, we can order the printing of async data, but this doesn't work so well for NSArrays in iOS, where hole-y, sparse arrays don't exist. What is the right way of populating an array, in order, from Firebase in iOS? I think this can be accomplished with a .json tacked onto the end of a URL for a REST call, but want to try to stick with the native Firebase iOS API. Thanks.
*Edit: * looking for a simple alphabetical sort. It looks like this should happen in Rest, and does with the following URL in REST:
https://mobilefeast.firebaseio.com/foodtrucks/.json
But I can't seem to replicate the same ordering with the iOS Firebase API.