Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jimerman

macrumors newbie
Original poster
Feb 10, 2010
13
1
Thanks for helping a newb out!! This is not making sense to me. I did find another thread in this forum with another guy who had a typo in his delegate method, but I don't have that typo and it still shows up as questionmarks. What am I missing?

First, I have a view controller that is the data source for the picker. In the view controller implementation, I have the following:

1. I have an NSArray* property "categories" - the initWithNibName method initializes these. The initialization looks something like this:

Code:
categories = [[NSArray alloc] initWithObjects:@"Indoors", @"Outdoors", nil];

2. I have the UIPickerViewDelegate and UIPickerViewDataSource protocols adopted.

3. I have the following methods:

Code:
#pragma mark -
#pragma mark UIPickerViewDataSource

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return [categories count];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}


#pragma mark -
#pragma mark UIPickerViewDelegate

// Retrieve the value for the row to display
- (NSString *)pickerView:(UIPickerView *)pickerView 
			 titleForRow:(NSInteger)row 
			forComponent:(NSInteger)component
{
    return [categories objectAtIndex:row];
}

When I run and set a breakpoint in the pickerView:titleForRow:forComponent, it doesn't break.
 
When I run and set a breakpoint in the pickerView:titleForRow:forComponent, it doesn't break.

That indicates the your pickerView hasn't had the delegate set.

Assuming you have the picker in an Interface Builder file, control drag from it to Files Owner and attach to both the delegate and the datasource. Also remember that Files Owner needs its Type set to your customer view controller, or what ever Class is handling your actions and outlets.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.