I'm having a hard time trying to understand a method in the Objective-C's NSMutableArray class. I created an array using the arrayWithCapacity: static method of this class, just like this:
NSMutableArray * myArray = [NSMutableArray arrayWithCapacity: 10];
Then I tried to access an element inside the array:
id myVariable = myArray[5];
And that's what I get:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds for empty array'
Why does it happen? Did I misunderstand anything about the method description?
Thanks for the help.