• 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: Advice needed about a possible bug in NSMethodSignature or NSInvocation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Advice needed about a possible bug in NSMethodSignature or NSInvocation


  • Subject: Re: Advice needed about a possible bug in NSMethodSignature or NSInvocation
  • From: Chris Kane <email@hidden>
  • Date: Wed, 10 Mar 2004 07:49:31 -0800

On Mar 3, 2004, at 4:39 PM, Thomas Lachand-Robert wrote:
The small test program below do exactly that, it calls two methods with equal return type, one declared as (NSObject<NSCopying>*) and the other as (Copy*) after a "typedef NSObject<NSCopying> Copy". No problem with a standard call, but I get the following output for a call via an NSInvocation:
Signature for method 'test1' = @, result address = 0x9a004.
Signature for method 'test2' = ^{NSObject=#}, result address = 0x30d510.

You get different results because the two type signatures created by the compiler mean different things. Check out the typedef of 'id' in the /usr/include/objc/objc.h: a pointer to a struct containing a pointer to a class. Basically, id ('@') is a special case meaning object, in interpreting the types, and pointer-to-Class[-pointer] or pointer-to-struct-containing-Class[-pointer]-as-first-member are handled more literally.

This is probably because you are separating the pointer from the type declaration. You are returning Copy *, which means that in that particular case you are returning a pointer to a Copy but in other cases you might use Copy without using a pointer to it. I think the behavior here is arguably correct, without too much effort, or if not, the That's Just The Way It Works Principle would apply.

Try changing this:
typedef NSObject<NSCopying> Copy;
to this:
typedef NSObject<NSCopying> *Copy;
and change uses of Copy.


Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
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.


  • Follow-Ups:
    • Re: Advice needed about a possible bug in NSMethodSignature or NSInvocation
      • From: Thomas Lachand-Robert <email@hidden>
References: 
 >Advice needed about a possible bug in NSMethodSignature or NSInvocation (From: Thomas Lachand-Robert <email@hidden>)

  • Prev by Date: Re: NSTableView eating keyDowns?
  • Next by Date: Writing an image from a text view to file
  • Previous by thread: Advice needed about a possible bug in NSMethodSignature or NSInvocation
  • Next by thread: Re: Advice needed about a possible bug in NSMethodSignature or NSInvocation
  • Index(es):
    • Date
    • Thread