1, Nsset
1. is an unordered collection class that manages multiple objects, with the greatest feature being that duplicate objects are not allowed in the collection, and that the mathematical set meanings are the same
2. Other functions and Nsarray are the same except for disorder and no repetition
2, Nsarray
1. An array is a set of ordered sets,
2. The index is indexed to each element in the array, as the string,
3. Arrays also have variable groups (Nsmutablearray) and non-variable groups (Nsarray),
4. Cannot save basic data type, struct data type in array, need to use NSNumber and nsvalue for data encapsulation
Code Listing 1:
Code Listing 2:
Encapsulates a class MyClass, stored with an array myclass
In the MAIN.M:
Code Listing 3:
3, Nsmutablearray (variable group)
1.NSMutableArray (variable group)
is a modifiable array class defined by objective-c
It's a subclass of Nsarray.
2. Creating an array
nsmutablearray* Array=[nsmutablearray arraywithobjects:@ "One", @ "one", @ "three", nil];
3. Adding elements
1. Adding an object at the end of the array
2. Inserting an object at a specified location
4. Deleting elements
Delete Element
1. Last Object
[Array Removelastobject];
2. Specifying objects
[Array removeobject:@ ""];
3. Specify the Location object
[Array removeobjectatindex:2];
4. Specifying a Range object
Nsrange r = {1, 2};
[Array removeobjectsinrange:r];
5. Emptying the array
[Array removeallobjects];
4. Nsdictionary (Immutable dictionary)
1. To find objects in the collection faster
2. By key (key) (name), the corresponding value (value).
Typically, the value of a key is a string type, and value is any object type
3.key values are not allowed to be duplicated, value values can be duplicated
4. The value of key and value is not allowed to be null
Objective-c data collection