LoginSignup
0
1

More than 1 year has passed since last update.

【キャッチアップ】swift

Last updated at Posted at 2021-09-06

変数についている!・?マークについて

!=値が入ってないとエラーになる = nilの場合はエラーが発生する(暗黙的アンラップ)
?=値が入っていなくてもエラーにならない = nilの場合でもエラーが発生しない 
こちらの記事に詳細が書いてありました。
https://qiita.com/og_omochi/items/0b255c790c4c3aecc630

アンラップの方法

  1. 強制アンラップ(変数!)
    nilの場合エラーが発生する
  2. if let
    nilの場合、処理がスルーされる
  3. guard let
    nilの場合、elseの処理が実行される
  4. オプショナルチェイニング(変数?)
    nilの場合でも処理が実行される

Delegate

tableViewCellで実行できない処理を記載できる
1. protcolで宣言する
2. 実行処理を記載する
3. 受け渡し元のViewにdelegateをセット
4. 受け渡し先のViewにdelegateを呼び出す

extension

クラスの機能を拡張することができるが、元の機能は変更できない

this class is not key value coding-compliant for the keyエラーについて

controllerのみから@IBOutlet@IBActionを削除すると発生します。
Show the Connections inspecterからも削除してやる必要があります。
こちらの記事に詳細が書いてありました。
https://qiita.com/Atsushi_/items/f7930dd00a2c2ea464cd

つまづきポイントRedundant conformance of 'mapViewController' to protocol 'MKMapViewDelegate'

classとextension両方に~Delegateを記載していると発生するので、classの方を削除すると解消する

【参考URL】

実践的なコーディングを紹介されています

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1