0

I created a Universal window app in Xcode 4.3.3. Later I added one View Controller(UniversalRootViewController) class without XIB. Then I created two XIB files(RootViewController_iPhone, RootViewController_iPad) and then connect these iPhone XIB file RootViewController_iPhone to the UniversalRootViewController class: RootViewController_iPhone -> Select File's Owner and changed the class name in Identity Inspector as UniversalRootViewController and then connect the view as outlet to UniversalViewController and did the same thing for RootViewController_iPad.

In App Delegate , I added the following lines of code.

UniversalRootViewController *controller = nil;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    controller = [[UniversalRootViewController alloc] initWithNibName:@"RootViewController_iPad" bundle:[NSBundle mainBundle]];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
    [self.window addSubview:navigationController.view];
}
else
{
    controller = [[UniversalRootViewController alloc] initWithNibName:@"RootViewController_iPhone" bundle:[NSBundle mainBundle]];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
    [self.window addSubview:controller];
}

Also I added these two key-value pairs in UniversalApp-Info.plist Main nib file base name : RootViewController_iPhone Main nib file base name (iPad) : RootViewController_iPad

When I run this application, the app creates by displaying the following error message.

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'

I connected XIB files properly to View Controller. I don't know why the app crashes. Please tell me the solution.

smily
  • 357
  • 1
  • 7
  • 18

2 Answers2

1

You will have to set the view outlet in the File's Owner to each view in the XIB file: - Go to one of the XIB file (iphone for example) and drag with the left mouse button from the file owner to the top view below in objects. Select view. - Do the same for the other XIB file

  • I'm not sure why this is happening in your case but usually you see this message if you missed the outlet connection or if you have a connection set up in your nibs to a property that is missing on the target object. In this case a property named view. – Daniela Dias Oct 17 '12 at 09:28
  • I made all connections between ViewController and XIB. But the app is not working. – smily Oct 17 '12 at 09:33
  • Have you checked if there is an outlet in the XIB that is connected to a property in header that does not exist anymore? – Daniela Dias Oct 17 '12 at 09:35
0

I solved my problem by removing the two key-value pairs of Nib files in Universal-Info.plist. Now the app works perfectly without any crash.I removed the following two lines

smily
  • 357
  • 1
  • 7
  • 18