On Apr 11, 2009, at 5:20 PM, Trygve Inda wrote:
-(void)threadMethod:(id)anObject
{
 NSAutoreleasePool*    pool = [[NSAutoreleasePool alloc] init];
 SEL                   comp = (SEL)anObject;

   ... Do stuff ...

[self performSelectorOnMainThread:comp withObject:nil waitUntilDone:NO];
 [pool release];
}

This crashes during detachNewThreadSelector. How can I pass a method to call
at the end of the thread processing as above?

There are a handful of issues here:

- a SEL is not an (id); if anything tries to -retain the SEL it is going to crash

- in general, casting outside of casting up/down class hierarchies is an indication that your code is wrong

If you really want to pass a selector around in a slot that normally holds objects, use NSStringFromSelector() and NSSelectorFromString().

However, with that said, that is generally an atypical design pattern. Not totally odd, but just not that typical. Raises a the "what are you trying to do?" flag, though.

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