Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
I have been using Objective C to make Apps for 8 months now, and I have never seen this before.

What's going on here?

int version[] = {0};
 

SteppingStone

macrumors member
Aug 6, 2012
70
0
This is a plain C array initialization. For some reason the author is initializing a one-element array of int. The syntax is a little more obvious when initializing an array with more than one element, e.g.

Code:
int myThreeElementArray[3] = {1,2,3};

will initialize an array of 3 ints with values 1,2,3. Since the right-hand-side contains explicit values, you could also omit the size and get the same result with

Code:
int myThreeElementArray[] = {1,2,3};

On the other hand, if you omit the explicit initializer, you'd have to specify the size.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.