Possible Duplicate:
Why does NSArray arrayWithObjects require a terminating nil?
It is said that we need to always use a nil as the last item for arrayWithObjects:
NSArray *wordList = [NSArray arrayWithObjects: @"hello", @"world", nil];
Why can’t arrayWithObjects not require the nil and just add the nil for us. Some forum said that’s because the nil act as a sentinel for other methods… but isn’t that an implementation issue that shouldn’t concern the user of the class?
For example, if other languages require
list = [1 ,2, nil] # Ruby
to build an array, it can be somewhat weird.
Because the automatic nil insertion would require some language or compiler extension.
In the case of the variadic list, the terminator’s required for the implementation to know when to stop reading.
Fortunately, your compiler supports sentinel attributes, so this should not be a problem if you turn up and pay attention to your compiler warnings.