Re: @selector not working with (id)anObject
Re: @selector not working with (id)anObject
- Subject: Re: @selector not working with (id)anObject
- From: Bill Bumgarner <email@hidden>
- Date: Sat, 11 Apr 2009 19:01:10 -0700
Sigh. Hit shift-cmd-D a bit too soon. :)
It does not seem I can invoke this on the main thread.
An NSInvocation?
[invocation performSelectorOnMainThread: @selector(invokeWithTarget:)
withObject: ...whatever... waitUntilDone: NO];
Basically I just need to use a function pointer. How does Cocoa do
this?
You can get the IMP if you want, but you don't need to for this.
I need to pass either someMethod or someOtherMethod and later call
it with
[self performSelectorOnMainThread:theMethod withObject:nil
waitUntilDone:NO];
Is this normally done with NSStringFromSelector and
NSSelectorFromString ?
This specific pattern? Yes -- encapsulating the selector in a string
works just fine.
In general? No.
Generally, if you have something that is going to be doing
calculations on another thread, you would create an instance of some
class that encapsulates the calculation. That class would also have
the bits necessary to figure out if it needs to call someMethod or
someOtherMethod on the main thread.
b.bum
_______________________________________________
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