Checking type Object Swift
Here example for check type object you don't what it is:
------------------------------------------------------------------------------------------------
var dataString = "Value Me"
var dataInt = 3.14
func checkingObject(value: Any) {
switch value {
case is Int:
print("Int it is")
case is Double:
print("Double it is")
default:
print("default is string", value)
}
}
checkingObject(value: dataString)
------------------------------------------------------------------------------------------------
No comments: