Get class name of UIViewController in swift

后端 未结 9 829
野的像风
野的像风 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:38

    Here is a swift3 version of isuru's answer.

    extension UIViewController {
        var className: String {
            return NSStringFromClass(self.classForCoder).components(separatedBy: ".").last!;
        }
    }
    

提交回复
热议问题