我想通过一个NSArray迭代和不断得到一个编译错误,权当我尝试在我的位置我的拼接数组的内容,以我的NSMutableString实例..

它只是告诉我,有一个“前语法错误;”它并没有告诉我一大堆。 在此行:

  [output appendString:[widget.children objectAtIndex:i]; 

我知道一定有什么事情了我的语法..

我的功能如下

- (NSString *)readArray
{
    NSMutableString *output = [[NSMutableString alloc] init];
    int i;
    int arraySize = widget.children.count;
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    for (i = 0; i < arraySize; i++)
    {
        [output appendString:[widget.children objectAtIndex:i];  (throws error here)
    }
    [pool release];
    return output;

}

由于事先

有帮助吗?

解决方案

你有一个未关闭托架,点击 需要]]在端部,而不是]

其他提示

NSArray有没有你在做什么,以及一个方法:

- (NSString *)readArray {
    return [widget.children componentsJoinedByString:@""];
}

另外,除非你调用该函数,亦常在紧密循环中没有太多的优势,有它创造它自己的自动释放池。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top