On Sat, Jan 10, 2009 at 2:00 PM, John Love <jote...@charter.net> wrote: > -performSelectorOnMainThread:withObject:waitUntilDone:, according to Apple > docs, is passed a SEL method that "should not have a significant return > value". > > I wish it to return a INT and I figure that that qualifies as > in-significant. Given that assumption, my real question is how to implement > it. I call: > > [self performSelectorOnMainThread:@selector:mySimpleSelector withObject:nil > waitUntilDone:YES]; > > (int) mySimpleSelector { > if (whatever) return 0; > else return 1; > } > > via my call to -performSelectorOnMainThread, just how do I access > -mySimpleSelector's returned INT? The simplest answer is to not have a > return value at all, but rather store the INTs in a global; but I figure > there is no time like the present to learn to solve this problem the right > way.
The discussion of return type is purely to ensure calling convention compatibility. -performSelectorOnMainThread:... has to assume a certain calling convention. It doesn't pay attention to the return value at all. As such, the logical calling convention to use is the one for void return. All it's saying here is that your method needs to be compatible with the void return calling convention (which in practice means it should return void, an integer type of native size or less, or a pointer) or else your code will potentially crash and burn. But it's just a compatibility measure. It doesn't provide any way to actually access the return value. Your method should always return void, and use another technique such as those discussed by other posts in this thread to communicate values back to the caller. Mike _______________________________________________ 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