Getting name of the class from an instance

后端 未结 7 2230
不思量自难忘°
不思量自难忘° 2021-01-30 07:45

I have the following problem: I get an instance of a class passed and want to know the name of the class of this instance. How to get this?

7条回答
  •  渐次进展
    2021-01-30 08:17

    If you are looking how get classname in Swift you can use reflect to get information about object.

    let tokens = split(reflect(self).summary, { $0 == "." })
    if let typeName = tokens.last {
        println(typeName)
    }
    

提交回复
热议问题