首页 > 代码库 > ios8 swift开发:显示变量的类名称

ios8 swift开发:显示变量的类名称

var ivar = [:]ivar.className // __NSDictionaryIvar i = 1i.className // error: ‘Int‘ does not have a member named ‘className‘

If you want to get the type of a primitive, you have to use bridgeToObjectiveC(). Example:

var i = 1

i.bridgeToObjectiveC().className // __NSCFNumber

println("\(object_getClassName(now))");