「Ios/swift/制御とループ」の版間の差分
提供: 初心者エンジニアの簡易メモ
(同じ利用者による、間の2版が非表示) | |||
行3: | 行3: | ||
} else { | } else { | ||
} | } | ||
+ | |||
+ | ==if一行== | ||
+ | row.title = (row.value ?? false) ? "The title expands when on" : "The title" | ||
==switch制御== | ==switch制御== | ||
行18: | 行21: | ||
for name in names { | for name in names { | ||
print(name) | print(name) | ||
+ | } | ||
+ | for _currentIndex in 1...tabItems.count { | ||
+ | print(tabItems.count[currentIndex - 1]) | ||
} | } | ||
// ディクショナリのループ | // ディクショナリのループ | ||
var user = ["name": "taro", "birth": "2000-10-10"] | var user = ["name": "taro", "birth": "2000-10-10"] | ||
for (key, val) in user { | for (key, val) in user { | ||
− | print( "key = \(key), val = \(val)" ) | + | print("key = \(key), val = \(val)") |
} | } |
2016年8月16日 (火) 05:42時点における最新版
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)") }