开发者

How do I use selectedRowInComponent method for UIPickerView

I have a UIPickerView object that has five rows that a user can select. I want to return the index of the row that the user selects on IBAction. When my method is called, I can return the text of the v开发者_开发知识库alue of what the user selected with this code: NSString * userChoice = [self pickerView:picker titleForRow:[picker selectedRowInComponent:0] forComponent:0]; I want to now return as an NSInteger, the row that is returned. The following code kills the program and I don't know why: NSLog(@"hello?? %@", [picker selectedRowInComponent:0]);

Any thoughts?? Is there a better method to use besides selectedRowInComponent?


try this

NSLog(@"hello?? %d", [picker selectedRowInComponent:0]);


An NSInteger is not an object it's a typedef for a long or int (see doc).

As Aaron pointed out, you can use any of the format specifiers: %d, %D, %i

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜