Swift 3.0 (also works with structs)
if type(of: someInstance) == type(of: anotherInstance) {
print("matching type")
} else {
print("something else")
}
More Related Contents:
- Converting Yearly Salary to Weekly in Swift
- structure vs class in swift language
- Saving custom Swift class with NSCoding to UserDefaults
- SwiftUI: How to make TextField become first responder?
- Sending json array via Alamofire
- What does “Fatal error: Unexpectedly found nil while unwrapping an Optional value” mean?
- How does String.Index work in Swift
- SwiftUI HStack with wrap and dynamic height
- What does “Protocol … can only be used as a generic constraint because it has Self or associated type requirements” mean?
- CFRunLoop in Swift Command Line Program
- What is the “some” keyword in Swift(UI)?
- How to generate a random number in a range (10…20) using Swift [duplicate]
- How to round a Double to the nearest Int in swift?
- ARKit – What do the different columns in Transform Matrix represent?
- Sort Dictionary by Key Value
- Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
- Calling a Swift class factory method with leading dot notation?
- What is the cause of this type error?
- Why do I need underscores in swift?
- Check empty string in Swift?
- Unable to run app in Simulator : An error was encountered while running (Domain = LaunchServicesError, Code = 0)
- Why is Equatable not defined for optional arrays
- How to avoid force unwrapping a variable?
- Using “if let…” with many expressions
- Get the top ViewController in iOS Swift
- Pass variables from one ViewController to another in Swift
- Multi-Component Picker (UIPickerView) in SwiftUI
- How to compare one value against multiple values in Swift?
- Swift Protocol inheritance and protocol conformance issue
- How to configure ContextMenu buttons for delete and disabled in SwiftUI?