Search code examples
iphoneobjective-cioscocoa-touchnsarray

Possible to init NSArray with empty values?


I have the following array which normally contains CGColor's:

_strokeColors = [[NSArray alloc] initWithObjects:NULL,NULL,NULL,NULL, nil];

I have some other arrays that run parallel with this array (i.e. _fillColors, _mutuablePaths) that have the same amount of values. I loop through all these arrays to check for data, and in this particular instance all of the _strokeColors have to be NULL. However, I notice that the above array has a size of 0.

What is the pattern for initializing an array like this that needs to read NULL for every value?


Solution

  • _strokeColors = [[NSArray alloc] initWithObjects:[NSNull null],[NSNull null],[NSNull null],[NSNull null], nil];
    

    should do the trick.