I have a very weird problem and has not been able to solve it yet.
This class is defined:
@interface EngineViewController : UIViewController
{
}
@property (nonatomic,readonly) IBOutlet GameView* vGameView;
@property (nonatomic,readonly) IBOutlet MainMenu* vMainMenu;
@property (nonatomic,readonly) IBOutlet CountryOverlay* vCountryOverlay;
@end
In init method I have this code:
if (![[NSBundle mainBundle] loadNibNamed:@"EngineViewController" owner:self options:nil])
{
NSLog(@"Failed to load menu nib!");
return NO;
}
// init
[self.view addSubview:vMainMenu];
The problem is, that vMainMenu is nil, vGameView is 0x1 and MainMenu class instance is assigned to vCountryOverlay (instead of vMainMenu).
Yes, in Xib, I have EngineViewController as File Owner and vMainMenu outlet set to UIView (MainMenu class) + other outlets not set.
I am out of ideas what to try. I tried to create an empty xib, set file owner to EngineViewController and set that vMainMenu outlet again. I have also tried to add a new "dummy" outlet property at the beginning. Tried to call loadNibNamed from a different part of the app, always the same.
But when I created a new, clean project, new nib, set owner, made a few outlets and did the same it worked just fine.
Why would loadNibNamed cause the first outlet to be set to 0x1 and "to offset" others, setting an instance which should be at the current outlet to the next one? Any idea what to try?
Thanks a lot!!