First, Nsarray and Nsmutablearray
(i) Nsarray non-variable group
(1) Basic introduction of Nsarray
Nsarray is an array used in OC, is object-oriented, manipulates objects in object-oriented form, and is an immutable group.
A disadvantage of C-language arrays is that only elements of the same data type are stored in arrays.
OC arrays can only hold OC objects, not non-OC objects, such as int, struct, enumeration, and so on.
(2) Creation of Nsarray
(3) Nsarray's visit
(4) Traversal of Nsarray
There are several ways to traverse an array:
First create an array
The first method: use for loop traversal
In-depth study of block traversal:
Each time an element is taken, it is passed to obj, and the block is called once, and the current element and index position are passed as parameters to the block.
Note that the 1:break is only used in two situations, the switch and the loop structure.
Note The 2:stop parameter is used to stop the traversal, and if the value is yes, it stops.
(ii) nsmutablearray variable array
(1) Basic use of Nsmutablearray
Note: Nsmutablearray inherits from Nsarray and almost has all the methods of Nsarray.
Ii. Nsset and Nsmutableset
(i) Nsset immutable collection
Basic use:
(ii) Nsmutableset variable set
Basic use:
(iii) Comparison of Nsset and Nsarray
(1) Common denominator:
1) are all collections and can hold multiple objects
2) Only OC objects can be stored, not non-OC object types (such as int, such as the basic data types and structure, enumeration, etc.).
3) is immutable and has a variable subclass.
(2) different points:
1) Nsarray Order, Nsset no order
Iii. Nsdictionary and Nsmutabledictionary
(i) Nsdictionary immutable dictionary
(1) Introduction
Dictionary in the real world: find specific content based on the index
Nsdictionary in OC: Find value based on key. Everything stored inside is a key-value pair.
(2) Creation of Nsdictionary
Note: The Quick Create dictionary is a compiler attribute.
(3) Nsdictionary's visit
(4) Traversal of nsdictionary
(ii) nsmutabledictionary variable dictionary
(1) Basic use of nsmutabledictionary
(2) Attention to the use of nsmutabledictionary
Note: This quick-create method only works with immutable dictionaries.
Foundation Framework-Collections