{"id":4440,"date":"2014-03-30T10:59:02","date_gmt":"2014-03-30T10:59:02","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/loadnibnamed-loads-to-different-iboutlets-collection-of-common-programming-errors\/"},"modified":"2014-03-30T10:59:02","modified_gmt":"2014-03-30T10:59:02","slug":"loadnibnamed-loads-to-different-iboutlets-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/loadnibnamed-loads-to-different-iboutlets-collection-of-common-programming-errors\/","title":{"rendered":"loadNibNamed loads to different IBOutlets?-Collection of common programming errors"},"content":{"rendered":"<p>I have a very weird problem and has not been able to solve it yet.<\/p>\n<p>This class is defined:<\/p>\n<pre><code>@interface EngineViewController : UIViewController\n{\n}\n@property (nonatomic,readonly) IBOutlet GameView* vGameView;\n@property (nonatomic,readonly) IBOutlet MainMenu* vMainMenu;\n@property (nonatomic,readonly) IBOutlet CountryOverlay* vCountryOverlay;\n@end\n<\/code><\/pre>\n<p>In init method I have this code:<\/p>\n<pre><code>if (![[NSBundle mainBundle] loadNibNamed:@\"EngineViewController\" owner:self options:nil])\n{\n    NSLog(@\"Failed to load menu nib!\");\n    return NO;\n}\n\n\/\/ init\n[self.view addSubview:vMainMenu];\n<\/code><\/pre>\n<p>The problem is, that vMainMenu is nil, vGameView is 0x1 and MainMenu class instance is assigned to vCountryOverlay (instead of vMainMenu).<\/p>\n<p>Yes, in Xib, I have EngineViewController as File Owner and vMainMenu outlet set to UIView (MainMenu class) + other outlets not set.<\/p>\n<p>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 &#8220;dummy&#8221; outlet property at the beginning. Tried to call loadNibNamed from a different part of the app, always the same.<\/p>\n<p>But when I created a new, clean project, new nib, set owner, made a few outlets and did the same it worked just fine.<\/p>\n<p>Why would loadNibNamed cause the first outlet to be set to 0x1 and &#8220;to offset&#8221; others, setting an instance which should be at the current outlet to the next one? Any idea what to try?<\/p>\n<p>Thanks a lot!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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:@&#8221;EngineViewController&#8221; owner:self options:nil]) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4440","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4440"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4440\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}