Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS NSMutableString返回奇怪的字符_Ios_Nsmutablearray_Nsarray_Nsmutablestring - Fatal编程技术网

iOS NSMutableString返回奇怪的字符

iOS NSMutableString返回奇怪的字符,ios,nsmutablearray,nsarray,nsmutablestring,Ios,Nsmutablearray,Nsarray,Nsmutablestring,我将几个单词组成一个数组,然后将所有单词放入一个可变字符串,然后将该字符串的每个字符组成一个可变数组。然而,“wordSplitted”是一个可变的字符数组,它在模拟器中每次启动应用程序时都会给出随机加扰字符,显示在日志中: 2012-07-22 09:12:01.108 xxx[4484:b603] wordSplitted contains: ( "", "", "\U221e", "-", G, N, P, "", "

我将几个单词组成一个数组,然后将所有单词放入一个可变字符串,然后将该字符串的每个字符组成一个可变数组。然而,“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);
NSArray*threeWords=[NSArray数组,其对象为:@“bil”,“huk”,“skje”,nil];
NSMutableString*allother=[[NSMutableString alloc]init];
/*
for(三个字的NSString*s)
{
[全部附加字符串:s];
}
*/
对于(int b=0;b<[三字计数];b++)
{
[AlltogetAppendString:[threeWords objectAtIndex:b]];
}
NSLog(@“allother包含%@”,allother);
//[三字稿];
[联合发布];
NSMutableArray*wordSplitted=[[NSMutableArray alloc]init];
//这个功能让我头痛
对于(int a=0;a<9;a++)
{
//还提供加扰字符
//[wordSplitted addObject:[NSString stringWithFormat:@“%C”,[allTogether characterAtIndex:a]];
NSRange range={a,1};
[wordSplitted addObject:[allTogether substringWithRange:range]];
}
NSLog(@“wordSplitted包含:%@”,wordSplitted);

如何显示字母表之类的普通字符?

您可以调用
[allTogether release]
,但稍后会引用它。通常,这会导致程序崩溃,但是
CFMutableArray
支持的某些特性使这种情况并不总是发生


基本上,在确定已使用完阵列之前,不要释放该阵列。

您可以调用
[allTogether release]
,但稍后会引用它。通常,这会导致程序崩溃,但是
CFMutableArray
支持的某些特性使这种情况并不总是发生

基本上,在确定已使用完数组之前,不要释放该数组。

关于字符串拆分

关于字符串拆分