Hen Shabat Hen Shabat - 1 year ago 72
Swift Question

How to get one String of dictionary that used as key from [String:Bool] in Swift

I have a dictionary:

var markedDays: [String : Bool] = [
"Sun" : true,
"Mon" : true,
"Tue" : true,
"Wed" : true,
"Thu" : true,
"Fri" : true,
"Sat" : true

Is there a way to use one string from my keys? Like
for example?
I need to compare it to another

Answer Source

Dictionary is unordered collection, why don't you just use Array instead of Dictionary:

let markedDays: [(String,Bool)] = [ ("Sun",true), ("Mon",true), ("Tue",true), ("Wed",true), ("Thu",true), ("Fri",true), ("Sat",true) ]

let day = markedDays[0].0
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download