How to add object at first index of NSArray

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

    Swift 3:

    func addObject(){
        var arrayName:[String] = ["Name1", "Name2", "Name3"]
        arrayName.insert("Name0", at: 0)
        print("---> ",arrayName)
    }
    
    Output:
    ---> ["Name0","Name1", "Name2", "Name3"]
    

提交回复
热议问题