質問編集履歴

2

エラーの件を追記しました

2017/03/27 07:30

投稿

apple2
apple2

スコア37

test CHANGED
File without changes
test CHANGED
@@ -42,13 +42,13 @@
42
42
 
43
43
 
44
44
 
45
- //こんな風にしたい
45
+ //こんな風にしたいのですが
46
46
 
47
47
  func say(_ i: Int){
48
48
 
49
- let arr = [label_001,label_002,label_003,label_004]
49
+ let arr = [label_001,label_002,label_003,label_004] as [Any]
50
50
 
51
- arr[i].text = "this is 00" + String(i)
51
+ ( arr[i] as AnyObject).text = "this is 00" + String(i)
52
52
 
53
53
  }
54
54
 
@@ -58,6 +58,6 @@
58
58
 
59
59
 
60
60
 
61
+ ```
61
62
 
62
-
63
- ```
63
+ Type 'Any' does not conform to protocol 'AnyObject' こういうエラーが出ます

1

たくさんの部品があるときに、その名前を直接書くんじゃない方法が知りたいんです

2017/03/27 07:30

投稿

apple2
apple2

スコア37

test CHANGED
File without changes
test CHANGED
@@ -28,11 +28,11 @@
28
28
 
29
29
  case 1: label_001.text = "this is 001"
30
30
 
31
- case 2: label_001.text = "this is 002"
31
+ case 2: label_002.text = "this is 002"
32
32
 
33
- case 3: label_001.text = "this is 003"
33
+ case 3: label_003.text = "this is 003"
34
34
 
35
- case 4: label_001.text = "this is 004"
35
+ case 4: label_004.text = "this is 004"
36
36
 
37
37
  default : break
38
38