我有一个可以用SwiftyJSON解析的json:
if let title = json["items"][2]["title"].string {
println("title : \(title)")
}
Run Code Online (Sandbox Code Playgroud)
完美的工作.
但我无法绕过它.我试过两种方法,第一种是
// TUTO :
//If json is .Dictionary
for (key: String, subJson: JSON) in json {
...
}
// WHAT I DID :
for (key: "title", subJson: json["items"]) in json {
...
}
Run Code Online (Sandbox Code Playgroud)
XCode不接受for循环声明.
第二种方法:
// TUTO :
if let appArray = json["feed"]["entry"].arrayValue {
...
}
// WHAT I DID :
if let tab = json["items"].arrayValue {
...
}
Run Code Online (Sandbox Code Playgroud)
XCode不接受if语句.
我究竟做错了什么 ?
我是Swift的新手,上课学习iOS编程.我发现自己难以理解如何在字典数组中搜索字符串值并将字符串值转储到数组中.这是从我的Xcode游乐场获取的.
我试图弄清楚如何:1)搜索字典数组2)将搜索结果转储到数组(我已经创建)
这些是字符词典.
let worf = [
"name": "Worf",
"rank": "lieutenant",
"information": "son of Mogh, slayer of Gowron",
"favorite drink": "prune juice",
"quote" : "Today is a good day to die."]
let picard = [
"name": "Jean-Luc Picard",
"rank": "captain",
"information": "Captain of the USS Enterprise",
"favorite drink": "tea, Earl Grey, hot"]
Run Code Online (Sandbox Code Playgroud)
这是上面列出的字符词典数组.
let characters = [worf, picard]
Run Code Online (Sandbox Code Playgroud)
这是我正在尝试写的功能.
func favoriteDrinksArrayForCharacters(characters:Array<Dictionary<String, String>>) -> Array<String> {
// create an array of Strings to dump in favorite drink strings
var favoriteDrinkArray = …Run Code Online (Sandbox Code Playgroud) NSLocalizedString(key, comment: "")当当前语言缺少键时,我无法从 Localizable.strings 加载字符串。NSLocalizedString 返回一个原始键
例如,当英语本地化存在字符串,但俄语缺少字符串时:
"config.updating" = "Update in progress...";
Run Code Online (Sandbox Code Playgroud)
当 iOS 语言设置为俄语时调用 NSLocalizedString 返回“config.updating”
NSLocalizedString("config.updating", comment: "") // "config.updating"
Run Code Online (Sandbox Code Playgroud)
NSLocalizedString 不应该访问 NSUserDefaults 中的“AppleLanguages”键来确定用户的设置并选择其他字符串吗?
给我一个示例和解释"循环array<Dictionary<String,String>>使用swift ...