oc-nsarray-nsmutablearray-array-variable array
1,oc language and C array differences An array of OC languages can only store object pointers and cannot store basic types
2, creation of arrays
(1), Initwithobjects:initwithobject
(2) @[@ "Jack" ...];
(2), Initwitharray:
(3), Arraywithobjects:arraywithobject
(4), Arraywitharray:
3, Array common methods
(1), gets the number of elements: Count [arr Count] Arr.count
(2), get the element of the corresponding position by index [arr objectatindex:1] arr[1]
(3), get index by object address Indexofobject [arr indexofobject:@ "Jack"]
(4) to determine if the array contains element Contailsobject:
(5), gets the last element of the array Lastobject:
(6), array elements are stitched into strings
4, the array is traversed for the for Forin Enumblock "Block Method"
Variable group
(1), add an element addobject: [arr addobject:@ "12"];
(2), insert element at specified position InsertObject:atIndex:insertobject
(3), append an array of Addobjectsfromarray:addobjectsfromarray
(4), delete the last element removelastobject remove End Object
(5), delete the element Removeobjectatindex at the specified location:
(6), remove all elements removeallobjects
(7), delete the specified element removeobject:
(8), delete the specified range of elements Removeobject:inrange:
(9), deletes the specified element according to an array Removeobjectsinarray: Deletes an element by the set of elements in the array
(10), modify array SetArray: integer instead of array
(11), replacing the element replaceobjectatindex:withobject at the specified position:
(12), swap array elements Exchangeobjectatindex:withobjectindex:
3, sort of variable group (1), Sortusingselector: (SEL) Comparator
[Muarr Sortusingselector: @sel (method name)];
Determines whether an object is an instance of a class 1,iskindofclass: (Class) AClass Description
1. Print the object's information must override the Description method
What is SEL 1,sel: type Selector
2, how to convert a method into a selector type: @selector and Nsselectformstring (method name)
3, the detection of the method that the selector represents is not implemented in the class that the object pointer belongs to 4, the function of the selector
oc-nsarray-nsmutablearray-array-variable array