<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Emmer Inc &#187; nib</title>
	<atom:link href="http://blog.emmerinc.be/index.php/tag/nib/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.emmerinc.be</link>
	<description>Tales from a .NET developer who's making the jump to the iPhone &#38; App Store wonderland.</description>
	<lastBuildDate>Wed, 23 Jun 2010 20:57:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Load view from nib improvement</title>
		<link>http://blog.emmerinc.be/index.php/2009/05/11/load-view-from-nib-improvement/</link>
		<comments>http://blog.emmerinc.be/index.php/2009/05/11/load-view-from-nib-improvement/#comments</comments>
		<pubDate>Mon, 11 May 2009 18:56:13 +0000</pubDate>
		<dc:creator>Yannick Compernol</dc:creator>
				<category><![CDATA[Cocoa Touch]]></category>
		<category><![CDATA[nib]]></category>

		<guid isPermaLink="false">http://blog.emmerinc.be/?p=482</guid>
		<description><![CDATA[One of the constants in a developer&#8217;s life is seeing code and knowing you&#8217;re doing it wrong, but not really knowing how to fix it and get it right. Due to whatever reason: no time&#8230; My Facebook like loading indicator article was no exception, the way I loaded a specific view from a separate nib [...]]]></description>
			<content:encoded><![CDATA[<p>One of the constants in a developer&#8217;s life is seeing code and knowing you&#8217;re doing it wrong, but not really knowing how to fix it and get it right. Due to whatever reason: no time&#8230; My <a href="http://blog.emmerinc.be/index.php/2009/04/25/facebook-like-loading-indicator/">Facebook like loading indicator</a> article was no exception, the way I loaded a specific view from a separate nib felt so bad. Yet I posted it since holding it back for another 4 weeks was no option either. A week ago I had a eureka moment and it all made sense at around 2am on a Saterday morning. Here&#8217;s the correct method to load a view from a separate nib file.</p>
<p>Instead of looping through the contents of the nib, the key are IBOutlets. Create a NSView IBOutlet in your controller class were you&#8217;ll want to use the view. Next step is to open your nib file which contains your external view and change the File Owner&#8217;s class identity to the controller class you&#8217;ve just extended with the IBOutlet for the view. Now just ctrl-drag from the File Owner to your view and select your desired IBOutlet from the list.</p>
<p>Now you&#8217;ve connected your controller and the external view, yet the IBOutlet will not be hooked up automatically when your controller&#8217;s created. This is a good thing because we can postpone loading the extra nib to when it&#8217;s really necessary saving resources for other, more important stuff. This is a practice Apple encourages, using multiple nib files and loading them dynamically when needed.</p>
<p>This is the code needed to load the nib, it&#8217;ll automaticall hook up your controller&#8217;s IBOutlet to your view.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> loadNibNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;YourNibName&quot;</span> owner<span style="color: #002200;">:</span>self options<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Simple? Indeed, yet it took me a while to realize using an external nib is basically just the same as putting all your views in a single nib container. It&#8217;s all based on hooking up IBOutlets.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emmerinc.be/index.php/2009/05/11/load-view-from-nib-improvement/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
