User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







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

This is an old revision of the document!


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"
)
advertising
objective-c/foundation.framework/nsarray.h/initwithobjects.1401479286.txt · Last modified: 2014/05/30 21:48 by 93.219.3.186

Impressum Datenschutz