NSArray initWithObjects
- (id)initWithObjects:(id)firstObj, ...
Parameters
firstObj, ...
A comma-separated list of objects ending with nil.
Return Value of [NSArray initWithObjects]
An array initialized to include the objects in the argument list. The returned object might be different than the original receiver.
Discussion of [NSArray initWithObjects]
After an immutable array has been initialized in this way, it can’t be modified.
NSArray initWithObjects example.
NSArray *list = [[NSArray alloc]
initWithObjects:@"Christie, Agatha",
@"Archer, Jeffrey", nil];
self.authorList = list;
[list release];
initWithObjects:@"Christie, Agatha",
@"Archer, Jeffrey", nil];
self.authorList = list;
[list release];
Example of [NSArray initWithObjects].
- (void)viewDidLoad{
[super viewDidLoad];
NSArray *tempArray = [[NSArray alloc]
initWithObjects:@"Christie, Agatha",
@"Archer, Jeffrey", nil];
self.authorList = tempArray;
[tempArray release];
NSString *titleString = @"Authors";
self.title = titleString;
[titleString release];
}
[super viewDidLoad];
NSArray *tempArray = [[NSArray alloc]
initWithObjects:@"Christie, Agatha",
@"Archer, Jeffrey", nil];
self.authorList = tempArray;
[tempArray release];
NSString *titleString = @"Authors";
self.title = titleString;
[titleString release];
}
NSArray initWithObjects example.
allFeaturesAvailableTabBarItemArray = [[NSArray alloc] initWithObjects:
issuesNavigationController,
thumbsViewController,
contentsViewController,
searchViewController,
favouritesViewController,
contactViewController, nil];
issuesNavigationController,
thumbsViewController,
contentsViewController,
searchViewController,
favouritesViewController,
contactViewController, nil];