With all the useful things you get from NSArray and NSMutableArray, why would you ever use a "C Style" array with Objective-C objects?
NSString *array[] = {@"dog", @"cat", @"boy"};
With all the useful things you get from NSArray and NSMutableArray, why would you ever use a "C Style" array with Objective-C objects?
NSString *array[] = {@"dog", @"cat", @"boy"};
For short, fixed arrays, the availability of a nice compact initialization syntax (as you've demonstrated) can be nice. In certain cases, a C style array may also offer a performance benefit compared to using NSArray. Another thing that comes to mind is that NSArray doesn't offer any built in support for multidimensional arrays, while multidimensional C arrays are easy.
And of course, there's the fact that you can only store objects in NSArray, not C-primitive types, but you asked specifically about using C arrays with Objective-C objects.
NSArray, because of typical objective-c features such as categories and method swizzling, which (in theory) could alter NSArray's behavior.sizeof(array) / sizeof(array[0]) to get the count? Could you use sizeof(array) / sizeof([array class]) ?All useful things come at a price.
Ever try making an NSArray of ints? You can't. You MUST use NSNumber.
Why? Because NSArray doesn't know what to do with things it doesn't know how to memory-manage... and the only things that conform to it's memory-management requirements are things based on NSObject.
It's just one example, but there are plenty of others.
Bottom line is, there is rarely ever one single "best" answer to anything. NSArray is no exception.