facebook twitter hatena line email

Ios/swift/制御とループ

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

if制御

if str == "hello" {
} else {
}

if一行

row.title = (row.value ?? false) ? "The title expands when on" : "The title"

switch制御

switch str {
case "hello":
    break;
case "good":
    break;
default:
    break;
}

for_inループ

var names:[String] = ["taro", "jiro", "saburo"]
for name in names {
    print(name)
}
for _currentIndex in 1...tabItems.count {
    print(tabItems.count[currentIndex - 1])
}
// ディクショナリのループ
var user = ["name": "taro", "birth": "2000-10-10"]
for (key, val) in user {
    print("key = \(key), val = \(val)")
}