I'm stuck. I have called the PFQuery and I NSlog my "Categories" and it all comes fine in the debugger area.
Where I'm having trouble is using this data to populate my UIPickerView from Parse.com.
Here is what I came up with.
Note that I have the necessary methods already for the Picker, I just need to use the data from parse to populate it.
_pickerData is a NSArray that populates the picker and I thought I could equal to objects to populate but this didn't work.
EDIT: What I have so far...
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
PFQuery *query = [PFQuery queryWithClassName:@"Categories"];
[query whereKeyExists:@"Category"];
[query orderByDescending:@"createdAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
_pickerData = objects;
NSLog(@"%@",objects);
}
else {
NSLog(@"error");
}
}];
self.categoryPicker.dataSource = self;
self.categoryPicker.delegate = self;
}
// The number of columns of data
- (int)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
// The number of rows of data
- (int)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return _pickerData.count;
}
// The data to return for the row and component (column) that's being passed in
- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return _pickerData[row];
}