Sort Dictionary Alphabetically Cannot assign value of type '[(key: String, value: AnyObject)]' to type 'Dictionary?'

前端 未结 2 2033
刺人心
刺人心 2021-01-18 07:45

I have this Dictionary, which I am getting from a web service:

let json = try JSONSerialization.jsonObject(with: data!, options:.allowFragments) as! Dictiona         


        
2条回答
  •  遇见更好的自我
    2021-01-18 08:27

    sorted(by:) Returns the elements of the sequence, sorted using the given predicate as the comparison between elements, so you can not use as a dictionary.

    For more info about this function you may read sorted(by:) documentation

提交回复
热议问题