• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Overriding methSigForSelect when forwarding?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Overriding methSigForSelect when forwarding?


  • Subject: Overriding methSigForSelect when forwarding?
  • From: Andrew Duncan <email@hidden>
  • Date: Tue, 27 Aug 2002 12:38:53 -0700

When forwarding a message, we have to override methodSignatureForSelector: because NSObject's (private) forward:: method uses it to construct an NSInvocation *before* calling forwardInvocation:. What to do in the overridden method?

* It seems to me that I should first call
+instanceMethodSignatureForSelector on [self class] and return
that value if non-nil just so that the semantics of the method
are unchanged for selectors that are already handled by the
receiver. This seems safe; didn't cause an infinite loop when I
tried it. Are we guaranteed that the class method will never call
the instance method?

If that's not nil I can go ahead and ask the delegate about the signature for the selector. But...

* If that's nil, what do we do? We can't return nil because
forward:: will call NSInvocation's invocationWithMethodSignature:
with the nil which evidently crashes. There are no other ways
(that I can see) to construct an NSMethodSignature than to get it
from an existing method. (Despite Apple's suggestion to
"preformulate" one.) If I intend to just absorb the message
instead of forwarding it I couldn't care less about the signature.

As it happens I just ask NSObject for some random signature and use that. But that's pretty lame; is there any preferred way to do this?

Andrew
email@hidden
http://www.andrewduncan.ws
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: NSTask _ NSFileHandle _ NSTexField
  • Next by Date: Re: AddressBook - ABMultiValue
  • Previous by thread: Re: NSTask _ NSFileHandle _ NSTexField
  • Next by thread: Which frameworks to link against to use Address Book APIs?
  • Index(es):
    • Date
    • Thread