How to check two instances are the same class/type in swift

Swift 3.0 (also works with structs)

if type(of: someInstance) == type(of: anotherInstance) {
    print("matching type")
} else {
    print("something else")
}

Leave a Comment