title: Stringify macro values in Objective C?
body: <p>I'm developing in XCode 4.2, and was wondering how I could stringify macro parameters? I was trying to use <code>#</code> as I thought I would do in <strong>C</strong>, but to no avail. Here is my macro:</p>
  
  <pre><code>#define ASSIGN_PROPERTY(PROP_NAME, PROP_NAME_PARAM) { \
    if (PROP_NAME_PARAM == nil) { \
      NSAssert(PROP_NAME != nil, @"#PROP_NAME is already nil"); \
      PROP_NAME = nil; \
    } else { \
      NSAssert1(PROP_NAME == nil, @"#PROP_NAME is already set, address=%p", PROP_NAME); \
      PROP_NAME = PROP_NAME_PARAM; \
    } \
  }
  </code></pre>
  
  <p>Then in a class that has <code>foo</code> as a property, I define its setter like so:</p>
  
  <pre><code>- (void) setFoo:(NSObject *)fooParam {
    ASSIGN_PROPERTY(foo, fooParam)
  }
  </code></pre>
  
  <p>Say a client calls <code>setFoo</code> with a non-nil value, but the <code>foo</code> property is already non-nil. I want the macro to print:</p>
  
  <blockquote>
    <p>foo is already set, address=0x5e55400</p>
  </blockquote>
  
  <p>But instead it's printing:</p>
  
  <blockquote>
    <p>#PROP_NAME is already set, address=0x5e55400</p>
  </blockquote>
  
  <p>Any advice? </p>