iphone not displaying array variables correctly
- by Rob
I was reading a tutorial on how to do a UIPicker and found this code:
- (IBAction)buttonPressed {
NSInteger row = [userPicker selectedRowInComponent:0];
NSString *selected = [userPickerData objectAtIndex:row];
NSString *title = [[NSString alloc] initWithFormat:@"You selected %a", selected];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:@"Thank you for Choosing." delegate:nil cancelButtonTitle:@"You're Welcome" otherButtonTitles:nil];
[alert show];
[alert release];
[title release];
}
- (void)viewDidLoad {
// [super viewDidLoad];
NSArray *array = [[NSArray alloc] initWithObjects:@"New", @"Frank", @"Bob", @"Thor", nil];
self.userPickerData = array;
[array release];
}
The UIPicker displays correctly and the variables in the picker also display correctly. When the button is pressed then the alert message does come up but it says, "You selected.." and then it's a bunch of gibberish. Why aren't the array variables being passed correctly?