User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







objective-c:foundation.framework:nsarray.h:initwithobjects

initWithObjects

 
- (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.

ObjC Sourcecode Example

    // ** 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);

Output for this example code

2012-12-02 21:42:27.469 NSArraySample[1583:11303] myArray: (
    1,
    "2. Object",
    "3. Object"
)

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
objective-c/foundation.framework/nsarray.h/initwithobjects.txt · Last modified: 2024/02/16 01:12 (external edit)

Impressum Datenschutz