Lots of similar questions but non with a solution that works in my case.
I try to write a simple FlipSideApp. Just two views with a single button each (flipBtn | flopBtn) to present the other view vice versa.
flip
on the first view works fine. flop
on the other view causes a
unrecognized selector sent to instance 0x6c3adf0
.
The App crashes after calling [self dismissViewControllerAnimated:YES completion:nil];
in file FlipSide.m (see code below). Where 0x6c3adf0
is the current address of self
which is an instance of FlipSide : UIViewController
in that case.
So I think the unrecognized selector mentioned in the error message is the dismissViewControllerAnimated:completion
-method.
While typing Xcode's CodeSense "recommends" that method.
According to the UIViewController Class Reference this method is known in iOS 5.0 SDK.
My Deployment Target is 5.0, Device iPhone, Base SDK iOS 5.0, Architecture Standard (arm7).
With a symbolic breakpoint set for all Exceptions the debugger stops at UIApplicationMain in main function. Which is nothing that give me a hint.
Zombie-Objects are enabled. Even when I think memory leaks are not the problem here.
What can I do that makes the selector be recognized?
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
File: "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__);
}
File: "FlipSide.h"
@interface FlipSide : UIViewController
- (IBAction)flopBtn:(id)sender;
@end
File: "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__);
}
Console OutPut is:
-[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
See Question&Answers more detail:
os