have a publish option in my app, where the user fills the information and it's send to my webservice.
I have the "form" on a modal view. And a function that I use to close it, when the button Cancel is touched.
When the publish button is touched, I start a thread, while the ws is in use.
I want to call my Cancel function when the ws operation is over.
Publish button:
self.myThread = [[NSThread alloc]initWithTarget:self selector:@selector(startThread) object:nil];
[self.myThread start];
startThread:
[self.ws publicar:self.registro];
[self.myThread performSelectorOnMainThread:@selector(Cancelar) withObject:nil waitUntilDone:NO];
[self.myThread cancel];
Cancelar:
-(IBAction)Cancelar{
[SingletonTelasAdicionar resetar];
[self dismissViewControllerAnimated:YES completion:nil];
}
When I touch the publish button I get this:
2014-04-02 20:11:25.540 PetFinder[5356:60b] -[NSThread Cancelar]: unrecognized selector sent to instance 0x112100030 2014-04-02 20:11:25.541 PetFinder[5356:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSThread Cancelar]: unrecognized selector sent to instance 0x112100030' * First throw call stack: ( 0 CoreFoundation 0x0000000101b6f495 exceptionPreprocess + 165 1 libobjc.A.dylib
0x000000010184799e objc_exception_throw + 43 2 CoreFoundation
0x0000000101c0065d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x0000000101b60d8d __forwarding + 973 4 CoreFoundation 0x0000000101b60938 _CF_forwarding_prep_0 + 120 5 Foundation
0x000000010144ca17 NSThreadPerformPerform + 227 6 CoreFoundation 0x0000000101afed21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 7 CoreFoundation 0x0000000101afe5f2 __CFRunLoopDoSources0 + 242 8 CoreFoundation 0x0000000101b1a46f __CFRunLoopRun + 767 9 CoreFoundation
0x0000000101b19d83 CFRunLoopRunSpecific + 467 10 GraphicsServices
0x0000000102cedf04 GSEventRunModal + 161 11 UIKit
0x00000001003f4e33 UIApplicationMain + 1010 12 PetFinder
0x0000000100008fc3 main + 115 13 libdyld.dylib
0x000000010381e5fd start + 1 14 ???
0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)