Swift获取对象的类型的方法type(of: <#T##T#>)
// type(of: <#T##T#>)
eg:
let date = Date()
type(of: date) // Foundation.Date.Type
print("\(type(of: date))") // Date
let str = "12345"
type(of: str) //String.Type
print("\(type(of: str))") // String
let number = NSNumber.init(value: 10)
type(of: number) //__C.__NSCFNumber.Type
print("\(type(of: number))") //__NSCFNumber
网友评论