你好 我有didFinishLaunching方法的問題。我真的很困惑什麼是問題,這就是爲什麼我粘貼我的所有代碼。問題是應用程序沒有啓動,它墜毀,並告訴我在控制檯此消息:DidFinish在應用iphone的問題中遇到問題
**[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'**
我使用此代碼 在Demo1appDelegate.h文件
#import <UIKit/UIKit.h>
#import "MapViewController.h"
@interface Demo1AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MapViewController *mapViewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end
而且在 Demo1AppDelegate.m文件
#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
這是非常好的問題。第一個定義@interface Demo1AppDelegate()@屬性(非原子,保留)的MapViewController在demo1Appdelegates.h文件和@sys到.m文件,將工作 – Harish 2011-05-25 09:08:23
我已經嘗試這一點,但它無法正常工作。它表現出同樣的按摩控制檯 – Rocky 2011-05-25 09:13:27