How to create array of unique object list in Swift

后端 未结 11 2107
猫巷女王i
猫巷女王i 2020-11-27 05:20

How can we create unique object list in Swift language like NSSet & NSMutableSet in Objective-C.

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 05:44

    Swift has no concept of sets. Using NSMutableSet in Swift might be slower than using a Dictionary that holds dummy values. You could do this :

    var mySet: Dictionary = [:]
    mySet["something"]= 1
    

    Then just iterate over the keys.

提交回复
热议问题