質問するログイン新規登録

回答編集履歴

1

修正

2016/05/22 22:30

投稿

_Kentarou
_Kentarou

スコア8490

answer CHANGED
@@ -17,4 +17,27 @@
17
17
  for (index, str) in str.enumerate() {
18
18
  mondaiTextLabels[index].text = str
19
19
  }
20
+ ```
21
+
22
+
23
+ IBOutlet Collectionを使っても同じ事ができます。
24
+ [IBOutlet Collectionの使い方](http://tryworks-design.com/?p=2068)
25
+
26
+ ```swift
27
+ // IBOutlet Collection
28
+ @IBOutlet var mondaiTextLabel: [UILabel]!
29
+
30
+ mondaiArray.append("a/b/c")
31
+ mondaiArray.append("1/2")
32
+ mondaiArray.append("あ/い/う/え")
33
+ mondaiArray.append("日本で一番/高い山は/富士山である。")
34
+
35
+ let str = mondaiArray[3].componentsSeparatedByString("/")
36
+
37
+ // ラベルを空文字で初期化
38
+ mondaiTextLabel.forEach{ $0.text = "" }
39
+
40
+ for (index, str) in str.enumerate() {
41
+ mondaiTextLabel[index].text = str
42
+ }
20
43
  ```