did you know that performSelectorInBackground actually retains the object is it called on. thus you can do:
MyCustomObject *obj = [[MyCustomObject alloc] init];
[obj performSelectorInBackground:@selector(someSelector:) withObject:nil];
[obj release];
And you won't have any errors even if "someSelector" takes a long time finish (downloading from internet, video exporting, etc..).
Saves you having a potentially unneeded extra class property. The new thread will retain 'obj' when the thread starts and release it when it is finished.
In documentation it says "This method retains the receiver and the arg parameter until after the selector is performed."
MyCustomObject *obj = [[MyCustomObject alloc] init];
[obj performSelectorInBackground:@selector(someSelector:) withObject:nil];
[obj release];
And you won't have any errors even if "someSelector" takes a long time finish (downloading from internet, video exporting, etc..).
Saves you having a potentially unneeded extra class property. The new thread will retain 'obj' when the thread starts and release it when it is finished.
In documentation it says "This method retains the receiver and the arg parameter until after the selector is performed."
Comments
Post a Comment