title: Get property name of object as string in Objective-C
body: <p>Suppose you have a class "Foo" with property "testProperty". The aim is to get property name (not value) as <code>NSString</code>. The question is probably duplicate of <a href="https://stackoverflow.com/questions/6615826/get-property-name-as-a-string">Get property name as a string</a> . But that answers did not help me because:</p>
  
  <ul>
  <li>I don't need all properties. I need only particular one.</li>
  <li>For <code>NSStringFromSelector(@selector(prop))</code> - anyway you have to input string.</li>
  </ul>
  
  <p>Suppose I have a function like </p>
  
  <pre><code>- (NSString *)propertyToString:(id)propertyOfObject
  </code></pre>
  
  <p>In that case I can use, for instance, for sorting </p>
  
  <pre><code>NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:[self propertyToString:foo.testProperty] ascending:NO]; 
  </code></pre>
  
  <p>So finally, the code will be clean.</p>