Length of an `int` array in Objective C
There isn't anything specific to Objective-C with an array of ints. You would use the same technique as if you were using C.
sz = (sizeof foo) / (sizeof foo[0]);
There is no such thing as array.length
in C. An int array in Objective-C is exactly the same as an int array in C. If it's statically defined like int foo[5]
, then you can do sizeof(foo)
to get the size — but only in the same function foo
is defined in (to other functions, it's just an int pointer, not an array per se). Otherwise, there is no inherent way to get this information. You need to either pass the size around or use sentinel values (like the terminating '\0' in C strings, which are just arrays of char).