回答編集履歴
1
ref
answer
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
`as!`でダウンキャストしているので、キャスト出来ないときに落ちます。
|
2
|
-
`as?`でダウンキャストし、Optional Binding(if let)でアンラップします。
|
2
|
+
`as?`でダウンキャストし、Optional Binding(`if let`)でアンラップします。
|
3
3
|
|
4
4
|
|
5
5
|
```swift
|
@@ -8,4 +8,8 @@
|
|
8
8
|
} else {
|
9
9
|
print("is not CAShapeLayer")
|
10
10
|
}
|
11
|
-
```
|
11
|
+
```
|
12
|
+
|
13
|
+
ref.
|
14
|
+
[Downcasting](https://docs.swift.org/swift-book/LanguageGuide/TypeCasting.html#ID341)
|
15
|
+
[Optional Binding](https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html#ID333)
|