Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size of NSArray

When I tried to check the size of NSArray which is declared without any capacity, I found it 4. Now the question is why it is always 4? please help me out to find it.... Thanks

like image 955
Milesh Avatar asked Feb 21 '11 05:02

Milesh


1 Answers

If you're talking about sizeof, it is not the right way to find out how much data an NSArray is holding. Objective-C objects are always accessed through pointers, and the size of a pointer on the iPhone is 4 bytes. That's what sizeof is telling you. To find out how many objects are in an array, ask the array for its count.

like image 129
Chuck Avatar answered Oct 27 '22 06:10

Chuck