Question

I've got a UIPickerView setup in an iPhone app - I'd like to load the picker with data that I pull from a database.

I'm using MagicalRecord.

My UIPickerView resides in my 'addEquipmentViewController.m'

It is the view shown when a person wants to add equipment to a location. The pickerview should show the locations from the database.

I have multiple locations loaded in the database - so they need to be grouped by location name (for example I might have multiple 'building1', or multiple 'building2' locations in the database, but just need it to show 'building1','building2' in the UIPickerView)

My [super viewDidLoad] currently looks like this:

NSArray *locations = [MetaLocations MR_fetchAllSortedBy:@"location" ascending:YES withPredicate:nil groupBy:@"location" delegate:self];

But it's giving me errors saying:

"Sending addEquipmentViewController *cont _strong' to parameter of incompatible type 'id'

Looking for ideas on how to accomplish my goal and get rid of these errors.

Was it helpful?

Solution

I've since gotten this working - I had to fetch all the data from the database, put it into a set (so I only got 1 of any duplicates) then change it to an array.

From there I simply used the array to fill the pickerview.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top