Nsarray
//creates an array with the specified argumentsNsarray *array = Nsarray alloc] initwithobjects:@" One",@" Both",@"three",@" Four", nil]; Nsarray*array = @[@" One",@" Both",@"three",@" Four"];//copy data from one array to anotherNsarray *array1 =[Nsarray Arraywitharray:array]; Nsmutablearray*mutablearray =[Nsmutablearray Arraywitharray:array]; //string splits the fractional group by the specified characterNsarray *array = [stringComponentsseparatedbystring:@","];//Inverse array Merge stringNSString *string= [Array componentsjoinedbystring:@","]; //The number of objects in the array;NSLog (@"%ld", Array.count)//[Array count];//gets the object at the specified index; NSLog (@"%@", [array Objectatindex:2]);
Nsmutablearray
//allocating capacity to an arrayNsarray *array = [Nsmutablearray arraywithcapacity: -]; //add an object at the end of an arrayNsmutablearray *array = [Nsmutablearray arraywithobjects:@" One",@" Both",@"three", nil]; [Array AddObject:@" Four"]; //deletes the specified index object in the array[Array Removeobjectatindex:1];
Common methods of Foundationのnsarray