Objective-C data set and objective-c set
1. NSSet
1. It is an unordered collection class that manages multiple objects. The biggest feature is that duplicate objects are not allowed in the collection, which is similar to the mathematical meaning of the set.
2. Apart from unordered and repeatable features, other functions are the same as those of NSArray.
2. NSArray
1. arrays are a group of Ordered Sets,
2. Obtain each element in the array through index subscript, which is the same as the string,
3. arrays also have NSMutableArray and NSArray ),
4. The basic data type and struct data type cannot be saved in the array. NSNumber and NSValue must be used for data encapsulation.
Code 1:
Code 2:
Encapsulate a class MyClass and store MyClass with Arrays
In main. m:
Code 3:
3. NSMutableArray (variable array)
1. NSMutableArray (variable array)
Is the modifiable array class defined by Objective-C.
Is a subclass of NSArray.
2. Create an array
NSMutableArray * array = [NSMutableArray arrayWithObjects: @ "one", @ "two", @ "three", nil];
3. Add Elements
1. Add an object to the end of the array
2. Insert an object at a specified position
4. Delete Elements
Delete Element
1. Last object
[Array removeLastObject];
2. Specify the object
[Array removeObject: @ "two"];
3. Specify the location object
[Array removeObjectAtIndex: 2];
4. Specify a range object
Nsange r = {1, 2 };
[Array removeObjectsInRange: r];
5. Clear the Array
[Array removeAllObjects];
4. NSDictionary (unchangeable dictionary)
1. To find objects in a set more quickly
2. Use key (key) (name) to specify the value ).
Generally, the key value is of the string type, and the value is of any object type.
3. duplicate key values are not allowed, and the value can be repeated.
4. The value of key and value cannot be blank.