Alex Rivera | Logout

Difference between [NSThread detachNewThreadSelector:] and -performSelectorInBackground

Asked 2010-01-19T09:46:41.187
26

I've been using -performSelectorInBackground in many of my apps, sort of oblivious to -detachNewThreadSelector. Now I am wondering what the differences are between the two. Are they pretty much interchangeable, or are there differences and places where one is superior to the other? Thanks!

Edit
Report

1 Answer

3

Corey, if you're running on a new thread and you're using [object autorelease], you'll need to create your own autorelease pool. Fairly simple to do:

- (void)uploadDataOnThread
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    // do something here...

    [pool release];
}
answered 2010-11-05T12:06:13.943

Your Answer