How to add object at first index of NSArray

后端 未结 10 708
离开以前
离开以前 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:17

    I know that we have six answers for insertObject, and one for creating a(n) NSMutableArray array and then calling addObject, but there is also this:

    myArray = [@[@"ALL ITEMS"] arrayByAddingObjectsFromArray:myArray];
    

    I haven't profiled either though.

提交回复
热议问题