两种方法:主要是对一串字符或者句子以字符转换为数组
方法一:
可以分割字母字符串或者汉字字符串
NSMutableArray*array1=[NSMutableArray new];
NSString *str = @"uuuu";
for (int i = 0;i <str.length; i++){
NSString *firstStr=[str substringWithRange:NSMakeRange(i, 1)];
[array1 addObject:firstStr];
}
NSLog(@"%@",array1[0]);
方法二:
可以分割字母字符串
NSMutableArray *array2=[NSMutableArray new];
NSString *str = @"uuuu";
for (int i = 0;i <str.length; i++){
char c = [str characterAtIndex:i];
[array2 addObject:[NSStringstringWithFormat:@"%c", c]];
}
NSLog(@"%@", array2);