Getting name of the class from an instance

后端 未结 7 2102
不思量自难忘°
不思量自难忘° 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:36

    OBJC:

    NSStringFromClass([instance class])
    

    SWIFT

    From instance:

    String(describing: YourType.self)
    

    From type:

    String(describing: self)
    
    0 讨论(0)
提交回复
热议问题