Using arrayWithCapacity:10
means that internally, the array will set itself up to hold 10 objects. But it still has no objects in it.
Normally, an empty array is created and setup to hold just a few objects. As you add more and more objects, the internal array needs to be resized. This means more memory needs to be malloced, then the old objects are moved to the new memory, and the old memory is cleaned up.
If you know the array will hold X number of objects, using arrayWithCapacity
allows the array to be more efficient. You can still add more objects but then the efficiency will be lost.
All of this aside, you can't access an array index beyond its current count. Since the count is 0 at first, you can't access any objects. You need to add objects before you can access them.