相关疑难解决方法(0)

崩溃了我的应用[NSMutableArray1 removeAllObjects] iphone sdk

我使用此代码来检查我的NSMutableArray中是否存在任何对象,如果是,我将它们全部删除但它崩溃了虽然有对象为什么?

    if([NSMutableArray1 count]==1)
    {
        [poemoptionslist removeAllObjects];
    }



    if ([NSMutableArray1 count]==0)
    {
        [poemoptionslist addObject: final1];
    }
Run Code Online (Sandbox Code Playgroud)

控制台输出

2010-10-18 03:42:13.166 app1 [33398:207] *由于未捕获的异常'NSInternalInconsistencyException'终止应用程序,原因:' - [__ NSCFArray removeObjectAtIndex:]:发送到不可变对象的mutating方法'*第一次调用时调用堆栈:(0 CoreFoundation
0x02e55b99 exceptionPreprocess + 185 1 libobjc.A.dylib
0x02fa540e objc_exception_throw + 47 2 CoreFoundation
0x02e0e238 + [NSException raise:format:arguments:] + 136 3
CoreFoundation
0x02e0e1aa + [NSException raise:format:] + 58 4
CoreFoundation
0x02e4d3c1 - [__NSCFArray removeObjectAtIndex:] + 193 5
CoreFoundation
0x02dfe973 - [NSMutableArray removeAllObjects] + 83 6
poemsoflove
0x0004dc8d - [submitpoem submitpoem:] + 18560 7 UIKit
0x003b77f8 …

iphone nsmutablearray

1
推荐指数
1
解决办法
3636
查看次数

标签 统计

iphone ×1

nsmutablearray ×1