Re: Type introspection with NSMethodSignature, deprecated NSObjCValueType?
Re: Type introspection with NSMethodSignature, deprecated NSObjCValueType?
- Subject: Re: Type introspection with NSMethodSignature, deprecated NSObjCValueType?
- From: Chris Kane <email@hidden>
- Date: Tue, 5 Feb 2008 10:01:48 -0800
On Feb 1, 2008, at 1:09 PM, Jim Correia wrote:
Given an arbitrary selector, and after having verified that
instances respond to the selector, I'd like to make sure the
method signature matches a particular form.
[...]
I was revisiting some old code today and noticed that I was perhaps
forwarding too many messages.
I have a view controller (my own class, predates NSViewController)
which hooks into the responder chain when it is active.
The view controller forwards action messages to the view so that it
can get them when it isn't key. (In this particular situation, it
makes sense for the view to be able to zoom, for example, even if
some other view in the window is key.)
For forwarding the messages, I have essentially 3 options:
1) Forward all unhandled messages from the controller to view.
2) Forward only action messages, as determined by introspection.
3) Forward messages only from a pre-defined list.
Today I am doing 1, which is more forwarding than is necessary. 3 is
a potential maintenance headache. So I was investigation options for
implementing #2.
So in this case, it sounds like you have a fallback position, which is
to forward anything you don't recognize via a test for situation #2.
But strcmp() is potentially too literal -- there are numbers and other
crud, potentially, and depending on what OS you're running on,
slightly different answers from those NSMethodSignature methods you
mentioned.
If there is a 'v' in the return type, and a '@' in the arg type
string, somewhere, and the number of arguments is 3, then you're
probably fairly safe.
Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden