objective c - xcode check if there is aobjectAtIndex or check array length -


I can not find it anywhere, I can search for the wrong words or words but I have to know how An array is a fixed length:

  if ([Score object otndex: 3]) {// code}   

This is an error and crash If the array is not long for this, but it should be clearly checked whether there is an index, and if not on the move ??

How can I check it without crashing ??

count NSArray returns the number of objects in the array if [MyArray count] return n are valid indices 0 to n - 1 . The index is not valid but there is no automated step. Before trying to reach the index, you need to make sure the index is valid.

 if ([score]] = 4) {id obj = [score objectattex3: 3]; }   

Comments