LoginSignup
13
13

More than 5 years have passed since last update.

Swiftでインスタンスがそのクラスであるか確認する

Last updated at Posted at 2015-01-16

Objective-CでいうところのisMemberOfClass:


class Test {
}

class Test2: Test {
}


let t = Test2()

t.dynamicType === NSObject.self // false
t.dynamicType === Test.self     // false
t.dynamicType === Test2.self    // true

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