noobie問題..什麼是檢查NSArray或NSMutableArray的索引是否存在的最佳方法是什麼?我到處搜索無濟於事!NSArray越界檢查
這是我曾嘗試:
if (sections = [arr objectAtIndex:4])
{
/*.....*/
}
或
sections = [arr objectAtIndex:4]
if (sections == nil)
{
/*.....*/
}
但兩者拋出不允許的「越界」的錯誤我繼續
(不回覆嘗試趕上,因爲那不是一個解決方案對我來說)
在此先感謝
媽..即時通訊這麼愚蠢。當然的!數組按順序填充。我把我的頭弄得一團糟。謝謝隊友+1 – spacebiker 2012-03-15 07:19:39
我認爲objective-c語言在這裏有點愚蠢。如果'[array objectAtIndex:outOfBounds]'返回'nil'而不是崩潰,我會更加舒服。 – turingtested 2016-05-24 10:20:04