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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to