Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Initialize arrays of NSString?

Tags:

objective-c

What's the easiest / fastest way to initialize an array of NSStrings in Objective C?

like image 418
user680406 Avatar asked May 05 '11 15:05

user680406


People also ask

How to create array in objc?

Creating an Array Object For example: NSArray *myColors; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; The above code creates a new array object called myColors and initializes it with four constant string objects containing the strings "Red", "Green", "Blue" and "Yellow".

How to create int array in Objective-C?

You can use a plain old C array: NSInteger myIntegers[40]; for (NSInteger i = 0; i < 40; i++) myIntegers[i] = i; // to get one of them NSLog (@"The 4th integer is: %d", myIntegers[3]);

What is NSMutableArray Objective-C?

The NSMutableArray class declares the programmatic interface to objects that manage a modifiable array of objects. This class adds insertion and deletion operations to the basic array-handling behavior inherited from NSArray . NSMutableArray is “toll-free bridged” with its Core Foundation counterpart, CFMutableArray .


1 Answers

NSArray *array = [NSArray arrayWithObjects:@"String1",@"String2",@"String3",nil]; 
like image 62
Tomas McGuinness Avatar answered Sep 23 '22 18:09

Tomas McGuinness