Swift 4.0 获取实例类型

2017-10-19  本文已影响163人  填坑侠

获取实例类型:

let testString = "test"
print(type(of: testString))

let testInt: Int = 7
print(type(of: testInt))

let testArray = [Any]()
print(type(of: testArray))

或者

 let value = paramsDict[key]!
 let paramType = String(describing:type(of: value)).self)

输出结果如下:

图片.png
上一篇下一篇

猜你喜欢

热点阅读