re: Type introspection with NSMethodSignature, deprecated NSObjCValueType
re: Type introspection with NSMethodSignature, deprecated NSObjCValueType
- Subject: re: Type introspection with NSMethodSignature, deprecated NSObjCValueType
- From: Ben Trumbull <email@hidden>
- Date: Fri, 1 Feb 2008 13:08:21 -0800
Suppose I want to verify that a given method signature looks like an
action method.
if ([methodSignature numberOfArguments] == 3 &&
0 == strcmp(@encode(void), [methodSignature methodReturnType]) &&
0 == strcmp(@encode(id), [methodSignature getArgumentTypeAtIndex: 2]) {
}
Is testing the argument types in this manner, with @encode(), going to
be future proof?
No, I don't believe strcmp() will be future proof. Depending on how
the method is declared, and which version of the compiler you use,
I've gotten very different results for object types:
static BOOL isTypeEncodingObject(char* enctext) {
// @ id
// @"Foobar" Foobar*
// ^# Class* aka id
// ^{Foobar=# .... } Foobar* with ivar decls. Antiquated.
...
It might be that for an application, asking about it's own methods
(presumably all compiled at the same time with the same compiler)
you'd be fine. Not sure about that, but it's clearly not the case
for a framework.
--
-Ben
_______________________________________________
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