2013-07-18 17 views
-1

有沒有辦法在([MyArray ObjectAtIndex:myindexpath.row])的周圍寫一些catch語句,這樣我就可以在不拋出異常的情況下運行該語句了?找出ObjectAtIndex是否返回一個對象

換句話說,我想寫這種表達的:

if ([MyArray ObjectAtIndex:myindexpath.row]) { 

// do some stuff if the object is in the array 

else { 

// do some other stuff 

} 

回答

2

肯定的是:使用邏輯&數學。

if (index < myArray.count) { 
    // ... 
} 
相關問題