#import <foundation/foundation.h>int main (int argc, const char * argv []) { @autoreleasepool { // nsmutablearray variable arrays inheritance and immutable nsarray // Nsmutablearray can create a mutable array object with all the methods of nsarray // NSMutableArray *arr = [[NSMutableArray alloc] initwithobjects:@ "C", @ "C", @ "OC", @ "UI", @ "NET", nil]; //Increase add /insert Delete remove change replace exchange [arr addobject:@ "QQQQQQ"];//add element to array nslog (@ "before:%@", arr); //adds an element at the end of the &NBSP;&NBSP;&NBSP;&NBsp; //[arr addobject:@ "Project"]; / /Insert //[arr insertobject:@ "project" in the specified location atIndex:1]; //[arr removeallobjects];//Delete all //Delete Last //[arr removeLastObject]; //Delete the //[of the specified index arr removeobjectatindex:0]; //Delete the specified element have a few deletions //[arr removeobject:@ "C"]; //Replacement //[arr replaceobjectatindex:0 withobject:@ "C"]; [arr exchangeobjectatindex:0 withobjectatindex:3]; nslog (@ "after:%@", arr), //variable space will increase decrease as data increases &NBSP;&NBSP;//Fast enumeration only reading group elements cannot change the array /* Fast Enumeration, At this point there will be an enumerator and the current array to establish an association, through this association to iterate over the array, the traversal of a modified monitor (iterator), to monitor whether the array has been modified, if once modified immediately crash crashes out */ for (NSString *str in arr) { //[arr exchangeobjectatindex:3 withobjectatindex:4]; &nBsp; //nslog (@ "%@", [arr objectatindex:0]); } } return 0;}
IOS Nsmutablearray Usage