如何在Swift中将字符串“ Hello”转换为数组[“ H”,“ e”,“ l”,“ l”,“ o”]?
在Objective-C中,我使用了以下方法:
NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[myString length]];
for (int i=0; i < [myString length]; i++) {
NSString *ichar = [NSString stringWithFormat:@"%c", [myString characterAtIndex:i]];
[characters addObject:ichar];
}
let joined = ", ".join(characters);
)数组会导致'String' is not identical to 'Character'
错误吗?