最佳答案
如何在 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];
}