I’m trying to load a UIViewController from code. I basically created a UIViewController generating a .xib file. I load it with the following code:
testViewController = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
this works but apparently (from what I have read) only the view is kept and the controller is deallocated (something which I have tested putting a breakpoint in the UIViewController’s dealloc method). I need to keep the UIViewController or otherwise, create a UIViewController with a UIView loaded from a nib file. How can this be achieved?
Not sure what you mean. What you’re doing there is correct. Since you’ve allocated it, you also -need to send a release statement to the view controller at some point, till then it shouldn’t be dealloc’ed.
A view might get released and set to nil under a special case where the application receives a memory warning, but I’m not sure if this was what you’ve read.