Whenever I run my app into a ‘iPhone 6.0 Simulator’, I get this weird behavior. The first time, it will successfully run but the 2nd time, it will crash with the error:
loaded the "IouView" nib but the view outlet was not set.'
This is reproducible and every other time, it would work and vice versa, it would crash. Here is my app structure:
In AppDelegate:
self.iouViewController = [[IouViewController alloc] initWithNibName:@"IouView" bundle:nil];
[iouViewController setIouTableArray:iouTableArray];
navController = [[UINavigationController alloc] initWithRootViewController:self.iouViewController];
[window setRootViewController:navController];
Then, in IouViewController.h:
@property (strong, nonatomic) IBOutlet UITableView *iouTableView;
Up until today, I have always coded my views (tableView, etc..) programmatically. With iPhone 5 having 4″ screen, I decided to stop fighting Apple and use IB along with ‘Auto Layout’ feature.
In my IouView.xib, this is the structure:
Objects: 'View',
Referencing Outlets: view - File's Owner
Objects: 'View'->'Table View'
Outlets: dataSource - File's Owner
Outlets: delegate - File's Owner
Referencing Outlets: iouTableView - File's Owner
There is actually another Table View within the View but I did not include it here. Please help as I am at a lost on how to proceed! Thank you so much.
Just throwing it out there since I may not be initialize my view controllers correctly, I commented out ‘loadView’ and use this as init:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
PS: I am building on iOS 6 SDK with Apple LLVM 4.1 and ARC enabled.
Update: Image from IB added:




Still at a lost, if you need any more code, please let me know. I created a new project with a simple navigation controller and it works for that new project but not mine. The crash is with the simulator.
I found a solution that does not crash the simulator anymore I think. I only got through the first view. This is the ‘thing’ I did. If someone have insights, let them share and hopefully will help others out as well. Special thanks to Carl Veazey for helping.
What I forgot to mention was that this code was done back in the days of iOS4 without ARC. When I switch, there were a lot of changes.
Following Carl’s suggestions, I took a look at ‘Build Phases’ -> ‘Compile Sources’ and saw to IouView.xib. So, I delete one. I ran the program and it shows a black screen. Finally, I looked at main.m
Original:
and change it to:
and i have to #import my AppDelegate. After making that change, I can run the program multiple times and it did not crash.