• 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
re: Type introspection with NSMethodSignature, deprecated NSObjCValueType
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Type introspection with NSMethodSignature, deprecated NSObjCValueType?
  • Next by Date: Re: Type introspection with NSMethodSignature, deprecated NSObjCValueType?
  • Previous by thread: Re: Setting to not open document at startup?
  • Next by thread: RE: Qt & NSWorkspace bug
  • Index(es):
    • Date
    • Thread