回答編集履歴

1

修正

2016/05/22 22:30

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -37,3 +37,49 @@
37
37
  }
38
38
 
39
39
  ```
40
+
41
+
42
+
43
+
44
+
45
+ IBOutlet Collectionを使っても同じ事ができます。
46
+
47
+ [IBOutlet Collectionの使い方](http://tryworks-design.com/?p=2068)
48
+
49
+
50
+
51
+ ```swift
52
+
53
+ // IBOutlet Collection
54
+
55
+ @IBOutlet var mondaiTextLabel: [UILabel]!
56
+
57
+
58
+
59
+ mondaiArray.append("a/b/c")
60
+
61
+ mondaiArray.append("1/2")
62
+
63
+ mondaiArray.append("あ/い/う/え")
64
+
65
+ mondaiArray.append("日本で一番/高い山は/富士山である。")
66
+
67
+
68
+
69
+ let str = mondaiArray[3].componentsSeparatedByString("/")
70
+
71
+
72
+
73
+ // ラベルを空文字で初期化
74
+
75
+ mondaiTextLabel.forEach{ $0.text = "" }
76
+
77
+
78
+
79
+ for (index, str) in str.enumerate() {
80
+
81
+ mondaiTextLabel[index].text = str
82
+
83
+ }
84
+
85
+ ```