title: How do I use objc_setAssociatedObject/objc_getAssociatedObject inside an object?
body: <p>If I use objc_setAssociatedObject/objc_getAssociatedObject inside a category implementation to store a simulated instance variable in a setter method, how would I access the key in the getter method since any variables declared in the setter method would be outside the scope of the getter method? </p>
  
  <p><strong>Edit:</strong> To clarify, if I were to use the following pattern, where should I declare STRING_KEY so that I could use it in both the setter and the getter method.</p>
  
  <pre><code>@interface NSView (simulateVar)
  -(void)setSimualtedString:(NSString *)myString;
  -(NSString *)simulatedString;
  @end
  
  @implementation NSView (simulateVar)
  
  -(void)setSimualtedString: (NSString *)myString
  {
      objc_setAssociatedObject(self, &amp;STRING_KEY, myString, OBJC_ASSOCIATION_RETAIN);
  }
  
  -(NSString *)simulatedString
  {
      return (NSString *)objc_getAssociatedObject(self, &amp;STRING_KEY);
  }
  
  @end
  </code></pre>