3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UIViewControllerのサブクラスの名前を取得する方法

Last updated at Posted at 2017-04-19

UIViewControllerの子クラスの名前を取得したいときに、以下を記述することで取得できる。

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

これを使って指定のViewControllerに対して、処理を行う実装を考えているけどベストじゃない気がする。

参考

3
2
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?