I’m using XCode 4 to develop an application that can be run on iPhone 3.1.3. On iOS4 Simulator works fine, but on my device, I get an error.
This is AppDelegate code where I get the error.
@implementation VoConstructorAppDelegate
@synthesize window=_window;
@synthesize viewController=_viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
I get the following error in self.window.rootViewController = self.viewController;:
2011-07-07 15:10:20.997 VoConstructor[159:207] *** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x11a9e0
2011-07-07 15:10:21.053 VoConstructor[159:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x11a9e0'
Any advice?
As rootViewController property appeared in UIWindow only in iOS4.0 you can’t use it for older platforms. For iOS 3.x you’ll have to add controller’s view to UIWindow manually and you code will look similar to: