Is there a way to pretty print Swift dictionaries to the console?

前端 未结 16 977
北海茫月
北海茫月 2020-12-07 09:33
NSDictionary *dictionary = @{@\"A\" : @\"alfa\",
                             @\"B\" : @\"bravo\",
                             @\"C\" : @\"charlie\",
                       


        
16条回答
  •  Happy的楠姐
    2020-12-07 10:09

    Just another way using Functional Programming

    dictionary.forEach { print("\($0): \($1)") }
    

    Output

    B: bravo
    A: alfa
    F: foxtrot
    C: charlie
    D: delta
    E: echo
    

提交回复
热议问题