Initializing an array with arrayWithObjects

If you’re creating an array and adding objects to it at initialization, in Cocoa, don’t forget that the last element of the list needs to be nil, it’ll save you debugging time ;).

NSMutableArray *array = [NSMutableArray arrayWithObjects: @"one", @"two", @"three", @"four", nil];

Developer reference.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.