0

From this answer, I know that I can get the name of the class type using

NSStringFromClass(YourClassName)

But I actually also need the name of the current object instance. So if I have code like this:

let loginForm = LoginFormViewController();

I want to actually get the loginForm in string, within the implementation of LoginFormViewController.

How can I do that?

Hamish
  • 74,809
  • 18
  • 177
  • 265
Chen Li Yong
  • 4,659
  • 6
  • 50
  • 101
  • 1
    No you can't – local variable names get stripped away upon compilation. What's the actual problem you're trying to solve here? – Hamish Jun 14 '17 at 14:03
  • @Hamish For debugging purposes. I print a lot of information in debugging console, and having the name of the variable will help me to locate through tons of words. Well, I guess I'm out of luck then. Thanks! – Chen Li Yong Jun 15 '17 at 01:48

0 Answers0