+ 1
How get max value of Dictionary in swift?
key of Dictionary is string and value is Int.
1 Answer
+ 1
let dic = ["a": 5, "b": 7, "c": 9]
var arr = [Int]()
for i in dic.values {
arr.append(i)
}
arr = arr.sorted(){$0 > $1}
print("Max value:\(arr[0])")