User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed



- (id)init

Returns an empty array.

Return Value - NSArray

ObjC Sourcecode Example

    // ** Init array **
    NSArray *myArray = [[NSArray alloc]init];
    // ** Output array **
    NSLog(@"myArray: %@", myArray);

If you look at the output for this example code, you`ll see that an empty array was initialized! Because this array is immutable it would make more sense to use a init-method that creates it with some objects or at least one object. For example initWithObjects.

Output for this example code

2012-12-02 21:27:29.423 NSArraySample[1536:11303] myArray: (

on the occasion of the current invasion of Russia in Ukraine

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

Impressum Datenschutz