Get class name of UIViewController in swift

后端 未结 9 901
野的像风
野的像风 2020-12-25 11:20

How to get class name of UIViewController Class in swift

In Objective C, we can do something like this :

self.appDelegate = (shAppDeleg         


        
9条回答
  •  盖世英雄少女心
    2020-12-25 11:24

    A simple way in swift 3 is to write the below code:

    for instances:

    let className = String(describing: self)
    

    for classes:

    let className = String(describing: YourViewController.self)
    

提交回复
热议问题