How to add object at first index of NSArray

后端 未结 10 870
离开以前
离开以前 2021-02-01 06:03

I want to add @\"ALL ITEMS\" object at the first index of NSARRAY.

Initially the Array has 10 objects. After adding, the array should contains 11 objects.

10条回答
  •  误落风尘
    2021-02-01 06:38

    you can't modify NSArray for inserting and adding. you need to use NSMutableArray. If you want to insert object at specified index

    [array1 insertObject:@"ALL ITEMS" atIndex:0];

    In Swift 2.0

    array1.insertObject("ALL ITEMS", atIndex: 0)
    

提交回复
热议问题