IOS Nsmutablearray Usage

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.