title: Can class_addMethod in Objective-C work only on a specific instance?
body: <p>I am trying to write some dynamic code where a user can try calling a method from a specific instance of a class and have it be resolved at runtime. The implementation to retrieve the information exists but the method to access it does not because it is on a per instance basis.</p>
  
  <p>For example, a user may want to call a method named "getSomething" which doesn't exist in the class:</p>
  
  <pre><code>[someInstance getSomething]
  </code></pre>
  
  <p>In this situation, I want to have an implementation resolved which has a variable return type that will only apply to the instance being worked on. I was considering using <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html#//apple_ref/c/func/class_addMethod">class_addMethod</a> from the Objective-C but I am not 100% sure of its behavior. On the documentation it claims that this can be used to add class or instance methods. Does calling this class add the method to only the specific instance or to the class so that every instance created afterward will have the method on it? I also read that once a method is added you can't remove it.</p>
  
  <p>Perhaps my approach isn't correct so if any alternatives are known I would appreciate it. I cannot use message forwarding because there is no class that understands the selector already implemented.</p>