Nsmutablearray (variable group) (ix)

Source: Internet
Author: User

1.

Nsmutablearray (variable group)

Nsmutablearray *MARR2 = [[Nsmutablearray alloc]initwithobjects:@ "1", @ "2", @ "3", nil];

Nsmutablearray *marr1 = [[Nsmutablearray alloc]init];//because it is a mutable array, you just need to give an empty group, so just use init

Add to

[Marr1 addobject:@ "1"];

[Marr1 addobject:@ "22"];

[Marr1 addobject:@ "CC"];

NSLog (@ "%@", marr1);/*2015-04-16 16:31:41.846 oclesson4_nsstring[2177:116050] (

1,

22,

Cc

)*/

2.

        //Delete, cannot cross the border, error

         [marr1 removeobjectatindex:0];

        NSLog (@ "%@", marr1);/*2015-04-16 16:32:46.124 OCLesson4 _NSSTRING[2188:116498] (

                            ,

                             cc

                             ) */

3.

Insert, can not cross the border, that is, error

[Marr1 insertobject:@ "AAA" atindex:0];

NSLog (@ "%@", marr1);/*2015-04-16 16:37:38.586 oclesson4_nsstring[2230:118462] (

Aaa

02n

Cc

)*/

4.

Exchange, can not cross the border, that is, error

[Marr1 exchangeobjectatindex:0 Withobjectatindex:2];

NSLog (@ "%@", marr1);/*2015-04-16 16:37:38.586 oclesson4_nsstring[2230:118462] (

Cc

22,

Aaa

)*/

5.

Change, can not cross the border, that is, error

Marr1[0] = @ "5";

NSLog (@ "%@", marr1);/*2015-04-16 16:37:38.586 oclesson4_nsstring[2230:118462] (

5,

02n

Aaa

)*/

Nsmutablearray (variable group) (ix)

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.