【发布时间】:2012-03-31 16:43:59
【问题描述】:
noobie question.. 检查 NSArray 或 NSMutableArray 的索引是否存在的最佳方法是什么。我到处找都无济于事!!
这是我尝试过的:
if (sections = [arr objectAtIndex:4])
{
/*.....*/
}
或
sections = [arr objectAtIndex:4]
if (sections == nil)
{
/*.....*/
}
但两者都会引发“越界”错误,不允许我继续
(不要回复 try catch,因为那不是我的解决方案)
提前致谢
【问题讨论】:
标签: cocoa nsmutablearray nsarray indexoutofboundsexception