0

EDIT: where I write "class" below, I mean "the actual class name of the class", not literally "class"!

For a UIViewController in a Universal app, we use:

[[class alloc] initWithNibName:nil bundle:nil];

or

[[class alloc] init]; // same thing

with files:

  1. class~ipad.xib
  2. class~iphone.xib

Apple correctly loads the device-specific NIB, as per Apple docs.

But if the UIViewController has a ".mm" extension, it fails every time. Seems to only happen with Obj-C++ viewcontrollers (changing the file extension "fixes" it).

Adam
  • 32,900
  • 16
  • 126
  • 153

1 Answers1

0

Ah, self-answering, found a workaround that works:

Instead of:

initWithNibName:nil bundle:nil

use:

initWithNibName:@"class" bundle:nil // where "class" == your classname, no extension

Whatever the bug is in Apple's code for reading NIB file based on filename ... this seems to fix it

Adam
  • 32,900
  • 16
  • 126
  • 153