• 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: Odd behaviour with NSInvocation, performSelectorOnMainThread and NSClassFromString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Odd behaviour with NSInvocation, performSelectorOnMainThread and NSClassFromString


  • Subject: Re: Odd behaviour with NSInvocation, performSelectorOnMainThread and NSClassFromString
  • From: Duncan McGregor <email@hidden>
  • Date: Sat, 17 Nov 2007 00:13:10 +0000

Thank you Peter, I think I'm understanding you.

So as I want performSelectorOnMainThread:aSelector:onTarget:withObject: to return id, I should leave the code alone, effectively returning Class*, and do the cast in any calling code.

On 16 Nov 2007, at 22:49, Peter Ammon wrote:


On Nov 16, 2007, at 2:26 PM, Duncan McGregor wrote:

	void* result = malloc([methodSignature methodReturnLength]); // TODO
	[invocation getReturnValue: result];
	NSLog(@"performSelectorOnMainThread returning %@", result);

-[NSInvocation getReturnValue:] takes a pointer to the buffer in which to store the return value. The return value in your test is of type Class, so after the call to getReturnValue:, you should think of the variable with identifier "result" of having type pointer-to-Class.


To get the actual return value, dereference the result: Class returnValue = *(Class *)result.

All ObjC objects also have a Class as the first word. That is why the log message indicates that you have a real QTMovie - the intial layout of your pointer-to-class buffer happens to match the layout for an ObjC object. It is not, however, a real object.

Hope this makes sense,
-Peter


_______________________________________________

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


References: 
 >Odd behaviour with NSInvocation, performSelectorOnMainThread and NSClassFromString (From: Duncan McGregor <email@hidden>)
 >Re: Odd behaviour with NSInvocation, performSelectorOnMainThread and NSClassFromString (From: Peter Ammon <email@hidden>)

  • Prev by Date: Re: NSMenuItem target binding
  • Next by Date: Frontmost window
  • Previous by thread: Re: Odd behaviour with NSInvocation, performSelectorOnMainThread and NSClassFromString
  • Next by thread: About InputManager and third-party applications
  • Index(es):
    • Date
    • Thread