iphone not displaying array variables correctly
Posted
by Rob
on Stack Overflow
See other posts from Stack Overflow
or by Rob
Published on 2010-05-10T01:19:05Z
Indexed on
2010/05/10
1:28 UTC
Read the original article
Hit count: 334
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?
© Stack Overflow or respective owner