home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Examples / Foundation / ForwardInvocation / TargetProxy.m < prev   
Text File  |  1996-02-05  |  1KB  |  44 lines

  1. /* TargetProxy.m created by blaine on Tue 30-Jan-1996 */
  2.  
  3. #import "TargetProxy.h"
  4.  
  5. @implementation TargetProxy
  6.  
  7. - initWithTarget:t {
  8.     target = [t retain];
  9.     return self;
  10. }
  11.  
  12. - (void)dealloc {
  13.     [target release];
  14.     [super dealloc];
  15. }
  16.  
  17. + proxyWithTarget:t {
  18.     TargetProxy *result = [self alloc];
  19.  
  20.     // always assume that init methods can substitute!
  21.     result = [result initWithTarget:t];
  22.     return [result autorelease];
  23. }
  24.  
  25. - (void)forwardInvocation:(NSInvocation *)invocation {
  26.     [invocation invokeWithTarget:target];
  27. }
  28.  
  29.  
  30. // The compiler knows the types at the call site but unfortunately doesn't
  31. // leave them around for us to use, so we must poke around and find the types
  32. // so that the invocation can be initialized from the stack frame.
  33. - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector {
  34.     return [target methodSignatureForSelector:selector];
  35. }
  36.  
  37.  
  38. // NSProxy does some things that we don't like...
  39.  
  40. - (NSString *)description {
  41.     return [target description];
  42. }
  43. @end
  44.