我有一個快速字典,我試圖訪問我的數組中的值。快速訪問字典中的值
我解釋我做如下所示:
["results": {
Democrats = {
percent = 67;
raw = 4;
};
Republicans = {
percent = 33;
raw = 2;
};
"total_answers" = 6;
}, "success": 1]
我又字典來獲得這樣的:
let test = dictionary["results"] as! [String : AnyObject]
["Democrats": {
percent = 67;
raw = 4;
}, "Republicans": {
percent = 33;
raw = 2;
}, "total_answers": 6]
我可以訪問諸如值:
let testing = test["total_answers"]
我想訪問百分比和原始值例如:
Democrats = {
percent = 67;
raw = 4;
};
百分比和原始密鑰是靜態的,但民主黨人是一個永遠不會相同的字符串。