键入Cast NSString到Integer iOS

时间:2014-03-21 08:06:46

标签: ios objective-c casting integer nsstring

我想在NSString之后输入类型为整数,我尝试了多项但不工作:

Nsstring *myString = @"123456  | 2333444 | 33333 | 3555";

1 个答案:

答案 0 :(得分:0)

尝试以下方法:

NSString *myString = @"123456  | 2333444 | 33333 | 3555";
NSArray *numbers = [myString componentsSeparatedByString:@"|"];
for(NSString *number in numbers)
    NSLog(@"%d",[number intValue]);