我有一个像NSString * str = @“123”这样的字符串.我想把这个字符串的数字填充到UIPickerView.But如何从这个字符串中获取数字?我添加了以下代码
- (void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component { int number = [str intValue]; if(component == 0) { } else if(component == 1) { } else { } }
解决方法
请看这个..
NSMutableArray *arrNumbers = [[NSMutableArray] alloc] initWithCapacity:[YOURSTRING length]]; for (i=0;i<[YOURSTRING length];i++) { unichaar ch = [YOURSTRING characterAtIndex:i]; NSLog(@"Processing charachter %c",ch); // If you really want [arrNumbers addObject:(id)ch]; }