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

ryanvanbelkum

macrumors newbie
Original poster
Jul 22, 2012
1
0
I'm am very new to iOS development, and am trying to get a UIPickerView to load my array of strings. All seems well, except when the simulator loads the view, the picker only shows question marks for every slot. I have the following code in my .m file, and in the storyboard I have dragged the datasource and the delegate over to the view controller. Please help!



Code:
- (void)viewDidLoad
{
    [super viewDidLoad];
    activities_ = [[NSArray alloc] initWithObjects:@"sleeping",@"eating",@"working",@"thinking",@"leaving",@"shopping",@"running",@"sick",nil];
	feelings_ = [[NSArray alloc] initWithObjects:@"awesome",@"sad",@"happy",@"excited",@"tired",@"nauceous",@"dumb",@"anxious",nil];
}

#pragma mark-
#pragma mark Picker Datasource Protocol

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


-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    if (component == 1){
        return [activities_ count];
    }else {
        return [feelings_ count];
    }
}
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.