Collection type, including nsarray, nsdictionary, and nsenumerator objects for traversal.
Create an unchangeable array object:
Nsarray * ary = [nsarray arraywithobjects: @ "title", @ "content", [nsnumber numberwithint: 2], nil];
Note that nsarray cannot store basic types such as float, Int, and double. Otherwise, it is set to 0. In addition, the above call must end with nil, which means nil cannot be stored in nsarray.
Traversal of array objects:
Nsenumerator * enu = [ary objectenumerator];
Id OBJ;
While (OBJ = [enu nextobject]) {
If ([OBJ iskindofclass: [nsstring class]) // ismemberof cannot be used here. Because the actual type returned here is _ nscfconstantstring.
{Nslog (@ "% @", OBJ );}
}
Use nsmutablearray to create a variable array. You can also use [ary mutablecopy] to directly return a variable array.
Nsmutablearray * Mary = [ary mutablecopy];
[Mary addobject: @ "This Is The spliter"];
In addition, each array has a componentsjoinedbystring method, which corresponds to componentsseperatedbystring of nsstring.
The last is nsdictionary.
[Nsdictionary * DIC = [nsdictionary dictionarywithobjectsandkeys: @ "Lucy", @ "name", [nsnumber numberwithint: 17], @ "Age", nil]; // you also need to end with nil
Nsenumerator * enu = [DIC keyenumerator];
ID key;
While (Key = [enu nextobject]) {