LoginSignup
0
0

More than 1 year has passed since last update.

【Swift エラー】Method '' with Objective-C selector 'delete:' conflicts with method 'delete' from superclass 'UIResponder' with the same Objective-C selector

Last updated at Posted at 2021-07-24

storybordから引っ張って、deleteという関数を作成しようとしたときに発生したエラー。
以下のように表示された。

Method 'delete' with Objective-C selector 'delete:' conflicts with method 'delete' from superclass 'UIResponder' with the same Objective-C selector

原因

よくわからないが、調べているとコンパイルエラーが発生しているらしい。
Swiftではオーバーロードが可能だが、Objective-cではオーバーロードができないため発生する。
Swiftでは引数または返り値が違う場合は同じ名前(識別子)で複数の関数を定義することができ、これを「オーバーフロー」という。
つまり、引数が文字列(String)や数字(Int)で違うなら、関数の名前は同じでもいいというもの。1つでもどこか違うなら、名前は同じでいいよってことですね。(ややこしいけど)

解決策

・名前を変える
私の場合、メモの削除機能だったため、deleteだった関数名をdeleteMemoとかに変更したらエラーは出なくなった。

0
0
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
0