作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个类似 NSString *str = @"123"
的字符串。我想将这个字符串的数字填充到 UIPickerView 中。但是如何从这个字符串中获取数字?我添加了以下代码
- (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];
}
关于iphone - 如何从 NSString 中获取整数的数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12072473/
我是一名优秀的程序员,十分优秀!