How to convert NSSet to [String] array?

前端 未结 4 1427
伪装坚强ぢ
伪装坚强ぢ 2021-02-09 07:00

I have an NSSet of Strings, and I want to convert it into [String]. How do I do that?

4条回答
  •  渐次进展
    2021-02-09 07:32

    You could do something like this.

    let set = //Whatever your set is
    var array: [String] = []
    
    for object in set {
         array.append(object as! String)
    }
    

提交回复
热议问题