title: Anyway to get string from variable name?
body: <p>Say I have my class </p>
  
  <pre><code>@interface Person : NSObject { NSString *name; }
  </code></pre>
  
  <p>I need to get the name of NSString's within my class </p>
  
  <pre><code>Person *person = [[Person alloc] init];
  NSLog(@"Name of variable %s\n", _NameofVariable_(person-&gt;name));
  </code></pre>
  
  <p><strong>Thanks for the answers, here's the solution I came up from the replies</strong> </p>
  
  <pre><code>//returns nil if property is not found
  -(NSString *)propertyName:(id)property {  
      unsigned int numIvars = 0;
      NSString *key=nil;
      Ivar * ivars = class_copyIvarList([self class], &amp;numIvars);
      for(int i = 0; i &lt; numIvars; i++) {
          Ivar thisIvar = ivars[i];
          if ((object_getIvar(self, thisIvar) == property)) {
              key = [NSString stringWithUTF8String:ivar_getName(thisIvar)];
              break;
          }
      } 
      free(ivars);
      return key;
  }  
  </code></pre>