关于removeObjectAtIndex [英] about removeObjectAtIndex

查看:66
本文介绍了关于removeObjectAtIndex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

appdata.items是NSMutableArray对象。

appdata.items is NSMutableArray object.

源代码

-(void)deleteAppDataItemId:(NSInteger)identifier{
    NSLog(@"%@", [appdata.items objectAtIndex:identifier]);
    NSLog(@"%i", identifier);
    [appdata.items removeObjectAtIndex:identifier];
}

log

2009-11-08 21:53:01.683 xxx[14283:207] (
    200,
    "",
    2009-11-08 21:52:53 +0900
)
2009-11-08 21:53:01.684 xxx[14283:207] 0
2009-11-08 21:53:01.685 xxx[14283:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)'

什么原因导致此错误?

推荐答案

将调试器设置为在 objc_exception_throw 上中断,然后在调试器中运行程序。遇到异常时,请查看堆栈跟踪。堆栈中的某些帧将采用可可或CF代码。其他人将在您的代码中。切换到代码中最上方的框架,然后开始检查变量。您应该以这种方式在短时间内找到问题。

Set the debugger to break on objc_exception_throw, then run your program in the debugger. When you hit the exception, look at the stack trace. Some of the frames in the stack will be in Cocoa or CF code; others will be in your code. Switch to the topmost frame that's in your code, and start examining variables. You should find the problem in short order that way.

这篇关于关于removeObjectAtIndex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆