Wednesday, 15 July 2015

cocoa - key/value pairs by name in Dictionary in Swift -



cocoa - key/value pairs by name in Dictionary in Swift -

is possible access key , value of single dictionary entry key & value, not 0 & 1?

in example:

let rockyplanets: dictionary<string, int> = [ // alphabetical order "earth": 3, "mars": 4, "mercury": 1, "venus": 2 ] eachplanet in rockyplanets { println("\(eachplanet.0) @ position \(eachplanet.1)") }

how can access key/values key or value (not index) in fashion:

for eachplanet in rockyplanets { println("\(eachplanet.key) @ position \(eachplanet.value)") }

is looking for?

for (key, value) in somedict { // ... }

in case:

for (planet, position) in rockyplanets { println("\(planet) @ position \(position)") }

cocoa swift

No comments:

Post a Comment