{"id":5310,"date":"2014-03-30T20:38:42","date_gmt":"2014-03-30T20:38:42","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/load-nib-from-variable-collection-of-common-programming-errors\/"},"modified":"2014-03-30T20:38:42","modified_gmt":"2014-03-30T20:38:42","slug":"load-nib-from-variable-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/load-nib-from-variable-collection-of-common-programming-errors\/","title":{"rendered":"Load NIB from variable-Collection of common programming errors"},"content":{"rendered":"<p>You cannot instantiate &#8220;UIViewController&#8221; with arbitrary NIBs, you have to instantiate &#8220;[whatever your custom view controller class is]&#8221; with the NIB for that class.<\/p>\n<p>It&#8217;s crashing because it&#8217;s trying to access properties that don&#8217;t exist in UIViewController.<\/p>\n<p>If you want to do this kind of dynamic view-controller loading, you need to do a bit more work, and use the special Class class method that lets you instantiate an object using a string for the class name, instead of hard-coded.<\/p>\n<p>Sometehing like:<\/p>\n<pre><code>Class viewControllerClass = NSClassFromString( nibVar );\nUIViewController* aController = (UIViewController*) [[viewControllerClass alloc] initWithNibName:nibVar bundle:nil];\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You cannot instantiate &#8220;UIViewController&#8221; with arbitrary NIBs, you have to instantiate &#8220;[whatever your custom view controller class is]&#8221; with the NIB for that class. It&#8217;s crashing because it&#8217;s trying to access properties that don&#8217;t exist in UIViewController. If you want to do this kind of dynamic view-controller loading, you need to do a bit more [&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-5310","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5310","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=5310"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5310\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}