Programming Reference/Librarys
Question & Answer
Q&A is closed
- (id)initWithObjects:(id)firstObj, ... NS_REQUIRES_NIL_TERMINATION;
Parameters firstObj, secondObj… Comma-separated objects ending with nil.
Return Value
An array initialized to include the parameters objects.
After an immutable array has been initialized in this way, it can’t be modified.
// ** Init some objects ** NSNumber *number = [NSNumber numberWithInt:1]; NSString *string = @"2. Object"; // ** Init array ** NSArray *myArray = [[NSArray alloc]initWithObjects:number, string, @"3. Object", nil]; // ** Output array ** NSLog(@"myArray: %@", myArray);
2012-12-02 21:42:27.469 NSArraySample[1583:11303] myArray: ( 1, "2. Object", "3. Object" )