我創建了幾個單詞的數組,然後將所有單詞放入可變字符串中,然後將此字符串的每個字符的可變數組。然而,「wordSplitted」,即字符的可變數組給隨機加擾的字符在模擬器應用程序的每次啓動,顯示在日誌中:iOS NSMutableString返回奇怪的字符
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);
如何顯示正常字符如字母?
你是對的!猜猜我睡得太少。 – wagashi 2012-07-22 07:32:10