views:

43

answers:

2

Hello!

Does nsarray count return the NUMBER of objects (I.E. the first object would be 1, etc) or does it return the max index of the object (I.E. the first one would be 0);

Thanks, Christian Stewart

+1  A: 

It returns the total number of objects. For example, if you have an object at index 0, 1, and 2, then it will return a count of 3.

AdamR
Thanks. Good answer. Wait did you just create an account to answer this? You only have 1 reputation lol.
Christian Stewart
A: 

It returns the total number of objects within the array, not the index.

NSArray *fastFoodPlaces = [NSArray arrayWithObjects:@"McDonalds", @"Burger King", @"Taco Bell", nil];

NSLog(@"Total Number of Objects: %i",[fastFoodPlaces count]);

Returns:

2010-08-29 18:25:50.963 StackOverflow[848:a0f] Total Number of Objects: 3

Nevermind, just saw the other two posts >.<

Richard
Wow... Where'd you get the return value from? That looks like a legit console return message lol! a0f?
Christian Stewart