I creat a instance of a class. Can I use some method to get the variable name, then I print out it? I just want this when I do some test project. I think I really mean is the variable name.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately, no, you can’t.
Object instances don’t have names. Classes have names. Methods have names. Properties have names. But object instances don’t. Variables have names, but they’re not unique to instances, and you don’t have access to that programmatically, anyway.
If you just invoke the
descriptionmethod, you’ll generally get a little something to identify the instance, but it’s not a name.UIViewobjects have a numerictagproperty, so for those you can set that property and identify your controls that way.