質問編集履歴
4
回答文に対する返事
test
CHANGED
File without changes
|
test
CHANGED
@@ -151,3 +151,19 @@
|
|
151
151
|
|
152
152
|
|
153
153
|
On Swift3での@objc推論を有効にする(非推奨)...onにするのは非推奨となっているようです。
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
@objcはswift4では使えないと思っていました。
|
158
|
+
|
159
|
+
勘違いですか。
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
私のpcでは警告文に
|
164
|
+
|
165
|
+
build setting to "Default" for the "SKtest" target.
|
166
|
+
|
167
|
+
"Default"にしろとあるようなのですが、現在"Default"になっていて変えようが
|
168
|
+
|
169
|
+
ありません。
|
3
コード部分を'''で囲む
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
|
13
13
|
swift4を使っています。
|
14
14
|
|
15
|
+
'''
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
import UIKit
|
18
18
|
|
19
19
|
import SpriteKit
|
20
20
|
|
@@ -120,7 +120,9 @@
|
|
120
120
|
|
121
121
|
|
122
122
|
|
123
|
+
}
|
124
|
+
|
123
|
-
|
125
|
+
'''
|
124
126
|
|
125
127
|
|
126
128
|
|
2
'''の追加とエラーメッセージの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
import UIKit
|
17
|
+
'''import UIKit
|
18
18
|
|
19
19
|
import SpriteKit
|
20
20
|
|
@@ -120,4 +120,32 @@
|
|
120
120
|
|
121
121
|
|
122
122
|
|
123
|
-
}
|
123
|
+
}'''
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
警告エラー
|
128
|
+
|
129
|
+
The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "SKtest" target.
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
@objcはswift4では警告になるのはわかっているのですが、その為には記述を変えるしかなくその方法がわからないのです。
|
134
|
+
|
135
|
+
'Swift 4で@objcに関するwarningが出たときの対処' というnetも見ていたのですが、
|
136
|
+
|
137
|
+
ベストな方法としては@objc を書き換える方法がベストだと思っていました。
|
138
|
+
|
139
|
+
質問の丸投げだと言われればどうしようもないですが ...
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
上記警告文では
|
144
|
+
|
145
|
+
build setting to "Default" for the "SKtest" target.
|
146
|
+
|
147
|
+
"Default"にしろとあるようなのですが、現在"Default"になっています。
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
On Swift3での@objc推論を有効にする(非推奨)...onにするのは非推奨となっているようです。
|
1
swiftの記述漏れがありました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,3 +11,113 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
swift4を使っています。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
import UIKit
|
18
|
+
|
19
|
+
import SpriteKit
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
class GameViewController: UIViewController {
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
override func viewDidLoad() {
|
28
|
+
|
29
|
+
super.viewDidLoad()
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
// Configure the view.
|
34
|
+
|
35
|
+
let skView = self.view as! SKView
|
36
|
+
|
37
|
+
skView.showsFPS = true
|
38
|
+
|
39
|
+
skView.showsNodeCount = true
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
/* Sprite Kit applies additional optimizations to improve rendering performance */
|
44
|
+
|
45
|
+
skView.ignoresSiblingOrder = true
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
// Create and configure the scene.
|
50
|
+
|
51
|
+
let scene = GameScene(size: skView.frame.size)
|
52
|
+
|
53
|
+
skView.presentScene(scene)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
// Pause the view (and thus the game) when the app is interrupted or backgrounded
|
58
|
+
|
59
|
+
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.handleApplicationWillResignActive(_:)), name: NSNotification.Name.UIApplicationWillResignActive, object: nil)
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.handleApplicationDidBecomeActive(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil)
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
override var prefersStatusBarHidden: Bool {
|
70
|
+
|
71
|
+
return true
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
override var shouldAutorotate: Bool {
|
78
|
+
|
79
|
+
return true
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
86
|
+
|
87
|
+
return UIInterfaceOrientationMask.portrait
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
override func didReceiveMemoryWarning() {
|
94
|
+
|
95
|
+
super.didReceiveMemoryWarning()
|
96
|
+
|
97
|
+
// Release any cached data, images, etc that aren't in use.
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
@objc func handleApplicationWillResignActive (_ note: Notification) {
|
104
|
+
|
105
|
+
let skView = self.view as! SKView
|
106
|
+
|
107
|
+
skView.isPaused = true
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
@objc func handleApplicationDidBecomeActive (_ note: Notification) {
|
114
|
+
|
115
|
+
let skView = self.view as! SKView
|
116
|
+
|
117
|
+
skView.isPaused = false
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
}
|