Reputation: 1423
Hello I have problem with didFinishLaunching methods. I am really getting confused about what was the problem and that's why I pasted all my code. The problem was the application didn't launch, it crashed, and it show me this message in console:
**[Demo1AppDelegate setMapViewController:]: unrecognized selector sent to instance 0x5649a30
2011-05-25 14:17:58.724 Demo1[10630:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Demo1AppDelegate setMapViewController:]: unrecognized selector sent to instance 0x5649a30'**
I am using this code In Demo1appDelegate.h file
#import <UIKit/UIKit.h>
#import "MapViewController.h"
@interface Demo1AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MapViewController *mapViewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end
And in Demo1AppDelegate.m file
#import "Demo1AppDelegate.h"
@interface Demo1AppDelegate ()
@property (nonatomic, retain) MapViewController *mapViewController;
@end
@implementation Demo1AppDelegate
@synthesize window;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
MapViewController *viewController = [[MapViewController alloc] init];
self.mapViewController = viewController;
[viewController release];
[window addSubview:self.mapViewController.view];
[window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[mapViewController release];
[window release];
[super dealloc];
}
@end
Upvotes: 1
Views: 1086
Reputation: 3177
You have to @synthesize mapViewController;
in Demo1AppDelegate.m
You should also add [mapViewController release];
in the dealloc
method of Demo1AppDelegate.m (with mapViewController being an instance variable).
Upvotes: 1
Reputation: 135
Hey! Where you add the subview
[window addSubview:self.mapViewController.view]; [window makeKeyAndVisible];
Try without "self"
[window addSubview:mapViewController.view]; [window makeKeyAndVisible];
Just a flying guess.
Upvotes: 0
Reputation: 14113
Try adding
@class MapViewController
before @implementation Demo1AppDelegate in Demo1AppDelegate.h
Upvotes: 0
Reputation: 558
the problem is in this line self.mapViewController = viewController;
you forgot @synthesize mapViewController;
Upvotes: 1
Reputation: 26390
I think
self.mapViewController = viewController;
is the problem. You do not have @synthesize
for mapViewController
. So you cannot access through self
Or another option is to try this
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
mapViewController = [[MapViewController alloc] init];
[window addSubview:mapViewController.view];
[window makeKeyAndVisible];
return YES;
}
Upvotes: 4
Reputation: 3464
You need to implement UIApplication
change
@interface Demo1AppDelegate : NSObject
to
@interface Demo1AppDelegate : NSObject < UIApplicationDelegate>
This will solve your problem
Upvotes: 1
Reputation: 6954
Add delegate as follows ... This might be the issue :
@interface Demo1AppDelegate : NSObject <UIApplicationDelegate>
Upvotes: 0