陈斌彬的技术博客

Stay foolish,stay hungry

Objective-c 字符串切割成数组

componentsSeparatedByString

将字符串切割成数组

 - (void)viewDidLoad
{
    NSString *a = [[NSString alloc] initWithString : @"apple,banana,pear" ];
    NSArray *b = [a componentsSeparatedByString:@","];
    NSString *a3 = [b objectAtIndex:2];
    NSLog(@"\n  b是: %@", a3);
}