#pragma mark Create array C
Nsmutablearray * Array =[[nsmutablearray alloc] initwithobjects:@ "a", @ "B", @ "C", nil];
Nsmutablearray * array1 =[nsmutablearray arraywithobjects:@ "a", @ "B", @ "C", nil];
Nsarray * array2 = @[@ "1", @ "2", @ "3"];
Nsmutablearray * Array3 = [[Nsmutablearray alloc]initwitharray:array2];
NSLog (@ "%@", array3);
#pragma mark variable array add element
[Array addobject:@ "D"];
[Array addobject:@ "E"];
NSLog (@ "%@", array);
#pragma mark variable array is incremented within the specified range
Array Current Range
[Array insertobject:@ "F" atindex:0];
NSLog (@ "%@", array);
#pragma mark appends an array to the array
Nsarray * Array4 = @[@ "G", @ "H", @ "I"];
[Array Addobjectsfromarray:array4];
NSLog (@ "%@", array);
#pragma mark replaces the elements in the array
[Array1 replaceobjectatindex:2 withobject:@ "HHH"];
NSLog (@ "%@", array1);
#pragma mark swaps the positions of elements in an array
[Array exchangeobjectatindex:0 withobjectatindex:5];
NSLog (@ "%@", array);
#pragma mark is removed from the array
1. Delete the last element
[Array Removelastobject];
NSLog (@ "%@", array);
2. Delete the element with the specified subscript
[Array removeobjectatindex:5];
NSLog (@ "%@", array);
3. Delete elements directly
[Array removeobject:@ "E"];
NSLog (@ "%@", array);
4. Remove elements within a specified range
In this range, if this element is present, delete the
If it doesn't exist, do not handle it.
0 position
5 length
Nsrange range = {0,5};
[Array removeobject:@ "G" inrange:range];
NSLog (@ "%@", array);
Remove from an array
Nsarray * arr [email protected][@ "A", @ "B", @ "C", @ "D"];
[Array Removeobjectsinarray:arr];
NSLog (@ "%@", array);
6 deletes all the elements in the array, but the array still exists, but there are no elements.
[Array removeallobjects];
NSLog (@ "array =%@", array);
#pragma mark modifies the array
[Array Setarray:arr];
NSLog (@ "%@", array);
All operations for iOS mutable arrays