我制作了一个由几个单词组成的数组,然后将所有单词放入一个可变字符串中,然后将该字符串的每个字符组成一个可变数组。但是,作为可变字符数组的“wordSplitted”在模拟器中每次启动应用程序时都会给出随机加扰字符,显示在日志中:
2012-07-22 09:12:01.108 xxx[4484:b603] wordSplitted contains: (
"",
"",
"\U221e",
"-",
G,
N,
P,
"",
""
)
应该是 b, i, l, h, u, k, s, k, j。
NSArray *threeWords = [NSArray arrayWithObjects:@"bil", @"huk", @"skje", nil];
NSMutableString *allTogether = [[NSMutableString alloc]init];
/*
for (NSString *s in threeWords)
{
[allTogether appendString:s];
}
*/
for (int b = 0; b < [threeWords count]; b++)
{
[allTogether appendString:[threeWords objectAtIndex:b]];
}
NSLog (@"allTogether contains %@", allTogether);
//[threeWords release];
[allTogether release];
NSMutableArray *wordSplitted = [[NSMutableArray alloc]init];
//this function gives me headache
for (int a = 0; a < 9; a ++)
{
//gives also scrambled characters
//[wordSplitted addObject:[NSString stringWithFormat:@"%C",[allTogether characterAtIndex:a]]];
NSRange range = {a,1};
[wordSplitted addObject:[allTogether substringWithRange:range]];
}
NSLog (@"wordSplitted contains: %@", wordSplitted);
如何显示字母等普通字符?