Remove specific object from array in swift 3

后端 未结 3 433
无人及你
无人及你 2020-12-29 05:43

\"Remove

I have a problem trying to remove a specific object from an array in Swift

3条回答
  •  没有蜡笔的小新
    2020-12-29 06:29

    I used the solutions provided here: Remove Specific Array Element, Equal to String - Swift Ask Question

    this is one of the solutions there (in case the object was a string):

    myArrayOfStrings = ["Hello","Playground","World"]
    myArrayOfStrings = myArrayOfStrings.filter{$0 != "Hello"}
    print(myArrayOfStrings)   // "[Playground, World]"
    

提交回复
热议问题