Help us understand the problem. What is going on with this article?

オプショナル使い方集[Swift]

クラスで絞る

//一番親のViewがSCNViewだったら
let scnView = self.view as! SCNView
//そいつの背景青にする
scnView.backgroundColor = UIColor.blue

https://qiita.com/hachinobu/items/2ecfc5999327fff20837

if letとか

if let HugaViewController = hogehuga as! HogeViewController {
            //hogehoge
}

!ではなく?にしてオプショナルにしなさいよ(nilを許容しなさいよ)ということらしい

Initializer for conditional binding must have Optional type, not 'HogeViewController'
//条件付きバインディングのイニシャライザには、「HogeViewController」ではなく「Optional」型が必要です
if let HugaViewController = hogehuga as? HogeViewController {
            //hogehoge
}

あとで追記

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした