LoginSignup
2

More than 3 years have passed since last update.

swiftで継承関係を無視したクラス比較の方法

Posted at

概要

swiftで継承関係を無視してclassの比較を行う為には、

type(of: 対象クラス) == 比較クラス.self

で比較を行う事ができる。

対象クラス is 比較クラス

だと継承しているかのチェックになるので注意。

補足

遥か昔、swift2.2までは

対象クラス.dynamicType == 比較クラス.self

で行なっていた内容です。

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
2