I read alot about what is the problem for exception “unrecog…” But i need something else
I have view with two buttons: Start and Delete, also i have two UILabels: oneLabel and secondLabel
So the I press button Start I start NSOperation thread started
And I give him labels (oneLabel,secondLabel) as params
to change text of labels on main loop i use
[oneLabel performSelectorOnMainThread:@selector(setText:) withObject:someString waitUntilDone:YES];
All works fine, but when i press button Delete – it’s deleting secondLabel from view with method
[secondLabel removeFromSuperview]
and then
secondLabel=nil;
So, after what i get exception. I understand why it happened – because the target object for message with selector setText if not available now becaus it’s nil.
And i get exception and app crashes.
How i can Catch this exception in this case?
For what i need it for? When use tableView controller with ImageView wich loads images in separate thread.
try this:
This will only call your method to be executed if your objects is still available and it responds to the specifed selector.
Hope this helps, Vlad