[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSProtocolChecker doesn't forward messages

From: J.F.Costa
Subject: NSProtocolChecker doesn't forward messages
Date: 24 Apr 2004 19:37:07 -0700

Hi, everybody.

        NSProtocolChecker instances don't forward the messages that are in
it's protocol. Here is NSProtocolChecker's forwarding method:

- (void) forwardInvocation: (NSInvocation*)anInvocation
  unsigned int  length;
  void          *buffer;

  if ((struct objc_method_description *)NULL
    != [self methodDescriptionForSelector: [anInvocation selector]])
    [[NSException exceptionWithName: NSInvalidArgumentException
                  reason: @"Method not declared in current protocol"
                  userInfo: nil] raise];

  [anInvocation invokeWithTarget: _myTarget];

  length = [[anInvocation methodSignature] methodReturnLength];
  buffer = (void *)malloc(length);
  [anInvocation getReturnValue: buffer];

  if (0 == strcmp([[anInvocation methodSignature] methodReturnType],
                  [[anInvocation methodSignatureForSelector:
                                  @selector(init: )] methodReturnType]) )
      if (((id)buffer) == _myTarget)
          buffer = self;
          [anInvocation setReturnValue: buffer];


        Notice that the comparison symbol in the protocol check is wrong, it
should be '=='. Besides that, there is something wrong with the
condition in the second 'if', because the former segfaults. What is
the correct condition?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]