`unrecognized selector sent to instance <OBJ_ADR>` after sending `rejectViewControllerAnimated: completion` to UIViewController
Many similar questions, but not with a solution that works in my case.
I am trying to write a simple FlipSideApp. Just two views with one button (flipBtn | flopBtn) to represent another view the other way around.
flipat first performance works great. flopin another view calls
unrecognized selector sent to instance 0x6c3adf0.
The application crashes after a call [self dismissViewControllerAnimated:YES completion:nil];in the FlipSide.m file (see code below). Where 0x6c3adf0is the current address self, which is an instance FlipSide : UIViewControllerin this case.
So, I think the unrecognized selector mentioned in the error message is a method dismissViewControllerAnimated:completion.
When you enter Xcode, CodeSense "recommends" this method.
According to the UIViewController Class Reference, this method is known in the SDK for iOS 5.0.
My deployment goal is 5.0, iPhone device, iOS 5.0 base SDK, architecture standard (arm7).
With a symbolic breakpoint set for all Exceptions, the debugger stops at UIApplicationMain in the main function. It gives me no clue. Zombie objects included. Even when I think a memory leak is not a problem here.
What can I do to recognize the selector?
File: " AppDelegate.m "
#import "FirstViewController.h"
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[[UIWindow alloc]
initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *viewController1 = [[[FirstViewController alloc]
initWithNibName:@"FirstViewController" bundle:nil] autorelease];
self.window.rootViewController = viewController1;
[self.window makeKeyAndVisible];
return YES;
}
File: " FirstViewController.h "
@interface FirstViewController : UIViewController
- (IBAction)flipBtn:(id)sender;
@end
: " FirstViewController.m"
…
- (IBAction)flipBtn:(id)sender {
NSLog(@"%s -- reached --", __PRETTY_FUNCTION__);
FlipSide* flipSide = [[FlipSide alloc] initWithNibName:@"FLipSide" bundle:nil];
[self presentViewController:flipSide animated:YES completion:nil];
NSLog(@"%s -- done --", __PRETTY_FUNCTION__);
}
: " FlipSide.h"
@interface FlipSide : UIViewController
- (IBAction)flopBtn:(id)sender;
@end
: " FlipSide.m"
#import "FlipSide.h"
- (IBAction)flopBtn:(id)sender {
NSLog(@"%s -- reached --", __PRETTY_FUNCTION__);
NSLog(@"self address is: %@", self);
// // // ??? unrecognized selector sent to instance ???
[self dismissViewControllerAnimated:YES completion:nil]; // <--
NSLog(@"%s -- done --", __PRETTY_FUNCTION__);
}
OutPut:
-[FirstViewController flipBtn:] -- reached --
-[FirstViewController flipBtn:] -- done --
-[FLipSide flopBtn:] -- reached --
self address is: <FLipSide 0x6c3adf0>
-[FLipSide flopBtn:] -- done --
-[FLipSide flopBtn:]: unrecognized selector sent to instance 0x6c3adf0