1.根据英文字符数组获取索引数组
+ (NSArray *)worldToNumberWithNum:(NSArray *)numArr
{
NSArray *wArr = @[@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"G",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z"];
NSMutableArray *indexArr = [[NSMutableArray alloc] initWithCapacity:0];
for (int i = 0; i < numArr.count; i ++) {
int index = (int)[wArr indexOfObject:numArr[i]];
[indexArr addObject:[NSString stringWithFormat:@"%d",index]];
}
return indexArr;
}
2.字符串转数组
除了系统提供的切割字符串,当切割类似@“abc”
+ (NSArray *)StrToArr:(NSString *)wStr
{
NSRange range;
NSMutableArray *subArr = [[NSMutableArray alloc] initWithCapacity:0];
for (int i = 0; i < wStr.length; i ++) {
range = [wStr rangeOfComposedCharacterSequenceAtIndex:i];
NSString *subStr = [wStr substringWithRange:range];
[subArr addObject:subStr];
}
return subArr;
}