<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Cocoa Tutorial: awakeFromNib vs applicationDidFinishLaunching</title>
	<atom:link href="http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/</link>
	<description>Taglines are for Windows programmers</description>
	<lastBuildDate>Mon, 26 Jul 2010 16:50:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-1252</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Tue, 09 Feb 2010 01:00:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-1252</guid>
		<description>&lt;p&gt;If the notifications are true NSNotifications then any controller can request to be notified of them using the NSNotificationCenter -addObserver... methods.  You just need to figure out the names of these methods and you are good to go.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If the notifications are true NSNotifications then any controller can request to be notified of them using the NSNotificationCenter -addObserver&#8230; methods.  You just need to figure out the names of these methods and you are good to go.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: taco</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-1251</link>
		<dc:creator>taco</dc:creator>
		<pubDate>Mon, 08 Feb 2010 20:04:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-1251</guid>
		<description>&lt;p&gt;So say LoginViewController has an -(FBSession *) didLogout:; method (madeup method name as I forget the exact name)... what is the proper way to implement RootViewController catching these notifications? I want certain functionality to not be available if FBSession&#039;s session (for facebook) is logged out. I actually want that to be app wide, but using this as an example.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>So say LoginViewController has an -(FBSession *) didLogout:; method (madeup method name as I forget the exact name)&#8230; what is the proper way to implement RootViewController catching these notifications? I want certain functionality to not be available if FBSession&#8217;s session (for facebook) is logged out. I actually want that to be app wide, but using this as an example.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: awakeFromNib and applicationDidFinishLaunching &#171; JongAm&#39;s blog</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-1217</link>
		<dc:creator>awakeFromNib and applicationDidFinishLaunching &#171; JongAm&#39;s blog</dc:creator>
		<pubDate>Fri, 01 Jan 2010 05:04:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-1217</guid>
		<description>&lt;p&gt;[...] is more detailed explanation at Cocoa Is My Girlfriend. Try reading it at least once. It is really well [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] is more detailed explanation at Cocoa Is My Girlfriend. Try reading it at least once. It is really well [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: mferris</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-231</link>
		<dc:creator>mferris</dc:creator>
		<pubDate>Mon, 31 Mar 2008 18:41:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-231</guid>
		<description>&lt;p&gt;A couple clarifications...&lt;/p&gt;

&lt;p&gt;-applicationDidFinishLaunching: will be sent to the application delegate as described above.  However, it is a notification as well.  NSApplication sends the notification NSApplicationDidFinishLaunchingNotification.  The application&#039;s delegate is automatically registered for this notification if it implements -applicationDidFinishLaunching:.  But any object can register for that notification.&lt;/p&gt;

&lt;p&gt;In general, most delegate methods in Cocoa that have Will or Did in their names are convenience covers for notifications.  (The definitive way to tell is in the delegate method takes a single (NSNotification*) parameter.)  For all these methods, there&#039;s a corresponding string constant for the notification name and any object can register to receive those notifications with NSNotificationCenter.  Multiple objects can receive any notification.&lt;/p&gt;

&lt;p&gt;Of course, to usefully register an object to receive the NSApplicationDidFinishLaunchingNotification, you must do it early enough to know that that notification has not already been sent...&lt;/p&gt;

&lt;p&gt;Someone asked who sends these messages.&lt;/p&gt;

&lt;p&gt;-awakeFromNib is sent by the nib loading machinery (which is implemented as a category addition to NSBundle in AppKit.  It&#039;s declared in AppKit/NSNibLoading.h)  -[NSBundle loadNibFile:externalNameTable:withZone:], specifically, will load the nib, get it all set up and connected, and invoke -awakeFromNib on all relevant objects.&lt;/p&gt;

&lt;p&gt;-applicationDidFinishLaunching: is invoked indirectly by NSNotificationCenter.  NSApplication posts the notification.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>A couple clarifications&#8230;</p>

<p>-applicationDidFinishLaunching: will be sent to the application delegate as described above.  However, it is a notification as well.  NSApplication sends the notification NSApplicationDidFinishLaunchingNotification.  The application&#8217;s delegate is automatically registered for this notification if it implements -applicationDidFinishLaunching:.  But any object can register for that notification.</p>

<p>In general, most delegate methods in Cocoa that have Will or Did in their names are convenience covers for notifications.  (The definitive way to tell is in the delegate method takes a single (NSNotification*) parameter.)  For all these methods, there&#8217;s a corresponding string constant for the notification name and any object can register to receive those notifications with NSNotificationCenter.  Multiple objects can receive any notification.</p>

<p>Of course, to usefully register an object to receive the NSApplicationDidFinishLaunchingNotification, you must do it early enough to know that that notification has not already been sent&#8230;</p>

<p>Someone asked who sends these messages.</p>

<p>-awakeFromNib is sent by the nib loading machinery (which is implemented as a category addition to NSBundle in AppKit.  It&#8217;s declared in AppKit/NSNibLoading.h)  -[NSBundle loadNibFile:externalNameTable:withZone:], specifically, will load the nib, get it all set up and connected, and invoke -awakeFromNib on all relevant objects.</p>

<p>-applicationDidFinishLaunching: is invoked indirectly by NSNotificationCenter.  NSApplication posts the notification.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-170</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Thu, 27 Mar 2008 14:58:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-170</guid>
		<description>&lt;p&gt;Thank you everyone for the great comments.  In reference to Cromagnon&#039;s question.  I have added Image 3 to show how you can see the difference.  Specifically, if you look at the class type of the File Owner, you will see that it is an NSApplication rather than another object type.  Also, applications usually only have one Main Menu reference and that will also be in the primary nib.&lt;/p&gt;

&lt;p&gt;Rainer,&lt;/p&gt;

&lt;p&gt;Thank you for the tip on application load.  I never put those two together before but now that you have for me it makes perfect sense.&lt;/p&gt;

&lt;p&gt;Paul,&lt;/p&gt;

&lt;p&gt;Yes I could have written that part better.  Hopefully with the addition of the new image it will be easier to understand.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thank you everyone for the great comments.  In reference to Cromagnon&#8217;s question.  I have added Image 3 to show how you can see the difference.  Specifically, if you look at the class type of the File Owner, you will see that it is an NSApplication rather than another object type.  Also, applications usually only have one Main Menu reference and that will also be in the primary nib.</p>

<p>Rainer,</p>

<p>Thank you for the tip on application load.  I never put those two together before but now that you have for me it makes perfect sense.</p>

<p>Paul,</p>

<p>Yes I could have written that part better.  Hopefully with the addition of the new image it will be easier to understand.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-166</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Thu, 27 Mar 2008 12:33:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-166</guid>
		<description>&lt;p&gt;I&#039;m confused about the statement &#039;When a nib is designed to be the primary or initial nib for an application it will have a reference to NSApplication in it&#039;. All nibs have a reference to NSApplication. It &#039;s the one called &#039;Application&#039;.&lt;/p&gt;

&lt;p&gt;Granted, I think that icon is new in IB3.0, so possibly you mean that the File&#039;s owner is set to NSApplication, but then I don&#039;t see how &#039;In this [second] example you can see the reference to the NSApplication in the nib&#039;&lt;/p&gt;

&lt;p&gt;Could you explain a bit more?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;m confused about the statement &#8216;When a nib is designed to be the primary or initial nib for an application it will have a reference to NSApplication in it&#8217;. All nibs have a reference to NSApplication. It &#8216;s the one called &#8216;Application&#8217;.</p>

<p>Granted, I think that icon is new in IB3.0, so possibly you mean that the File&#8217;s owner is set to NSApplication, but then I don&#8217;t see how &#8216;In this [second] example you can see the reference to the NSApplication in the nib&#8217;</p>

<p>Could you explain a bit more?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Rainer Brockerhoff</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-163</link>
		<dc:creator>Rainer Brockerhoff</dc:creator>
		<pubDate>Thu, 27 Mar 2008 10:38:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-163</guid>
		<description>&lt;p&gt;Also important: awakeFromNib can be called multiple times on the controller if you use the same controller for several nibs - say, you&#039;re using the app delegate as the owner of both the app&#039;s About Box and preferences dialog. So you&#039;ll need an extra guard test if you use awakeFromNib for anything but initializing the nib objects,&lt;/p&gt;

&lt;p&gt;Second important call in the app delegate is applicationWillFinishLaunching, which will be called earlier; in fact, while the icon is still bouncing in the Dock (applicationDidFinishLaunching is called when the icon stops bouncing). So this is a place to early-initialize application stuff.&lt;/p&gt;

&lt;p&gt;If your app is opened by double-clicking on a document icon, application:openFile: will be called on the app delegate &lt;em&gt;before&lt;/em&gt; applicationWillFinishLaunching is called. So if you implement that method too, you should do something like
[self performSelector:... withObject:filename afterDelay:0.0] to act on the file after the run loop gets going.&lt;/p&gt;

&lt;p&gt;Finally, the main run loop is started after applicationWillFinishLaunching returns.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Also important: awakeFromNib can be called multiple times on the controller if you use the same controller for several nibs &#8211; say, you&#8217;re using the app delegate as the owner of both the app&#8217;s About Box and preferences dialog. So you&#8217;ll need an extra guard test if you use awakeFromNib for anything but initializing the nib objects,</p>

<p>Second important call in the app delegate is applicationWillFinishLaunching, which will be called earlier; in fact, while the icon is still bouncing in the Dock (applicationDidFinishLaunching is called when the icon stops bouncing). So this is a place to early-initialize application stuff.</p>

<p>If your app is opened by double-clicking on a document icon, application:openFile: will be called on the app delegate <em>before</em> applicationWillFinishLaunching is called. So if you implement that method too, you should do something like
[self performSelector:... withObject:filename afterDelay:0.0] to act on the file after the run loop gets going.</p>

<p>Finally, the main run loop is started after applicationWillFinishLaunching returns.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Cromagnon</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-159</link>
		<dc:creator>Cromagnon</dc:creator>
		<pubDate>Thu, 27 Mar 2008 03:28:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-159</guid>
		<description>&lt;p&gt;&quot;When a nib is designed to be the primary or initial nib for an application it will have a reference to NSApplication in it.
In this example you can see the reference to the NSApplication in the nib.&quot;&lt;/p&gt;

&lt;p&gt;I am probably being a bit thick (fairly new to Mac development), but where should I see this reference to NSApplication?  I thought you meant the icon labelled Application, but that&#039;s in both examples.  Do you mean the MainMenu instead?  Sorry if I&#039;m asking a dumb question here.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>&#8220;When a nib is designed to be the primary or initial nib for an application it will have a reference to NSApplication in it.
In this example you can see the reference to the NSApplication in the nib.&#8221;</p>

<p>I am probably being a bit thick (fairly new to Mac development), but where should I see this reference to NSApplication?  I thought you meant the icon labelled Application, but that&#8217;s in both examples.  Do you mean the MainMenu instead?  Sorry if I&#8217;m asking a dumb question here.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: murph</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-157</link>
		<dc:creator>murph</dc:creator>
		<pubDate>Thu, 27 Mar 2008 02:47:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-157</guid>
		<description>&lt;p&gt;Also worth noting is that during the -awakeFromNib round your application&#039;s icon will continue to bounce in the Dock.  By the time the -applicationDidFinishLaunching: notification is sent, the bouncing will have ended.&lt;/p&gt;

&lt;p&gt;You can use this knowledge to influence the &quot;perceived&quot; launch time of your application, by segregating heavy initialization code into the latter method where it makes sense, reducing the number of launch-time Dock bounces.&lt;/p&gt;

&lt;p&gt;By the way, Marcus and Matt, the blog is a great read.  Keep the technical stuff coming!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Also worth noting is that during the -awakeFromNib round your application&#8217;s icon will continue to bounce in the Dock.  By the time the -applicationDidFinishLaunching: notification is sent, the bouncing will have ended.</p>

<p>You can use this knowledge to influence the &#8220;perceived&#8221; launch time of your application, by segregating heavy initialization code into the latter method where it makes sense, reducing the number of launch-time Dock bounces.</p>

<p>By the way, Marcus and Matt, the blog is a great read.  Keep the technical stuff coming!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-156</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Thu, 27 Mar 2008 00:40:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-156</guid>
		<description>&lt;p&gt;NSApplication calls the applicationDidFinishLaunching.&lt;/p&gt;

&lt;p&gt;As for the awakeFromNib it can vary greatly but on startup it is generally the NSApplication also.  Later in the applications life it is usually you :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>NSApplication calls the applicationDidFinishLaunching.</p>

<p>As for the awakeFromNib it can vary greatly but on startup it is generally the NSApplication also.  Later in the applications life it is usually you :)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: icy</title>
		<link>http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/comment-page-1/#comment-155</link>
		<dc:creator>icy</dc:creator>
		<pubDate>Wed, 26 Mar 2008 22:58:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/2008/03/26/cocoa-tutorial-awakefromnib-vs-applicationdidfinishlaunching/#comment-155</guid>
		<description>&lt;p&gt;Who is calling those methods? Is it the NSApplication instance or some other part of the runtime?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Who is calling those methods? Is it the NSApplication instance or some other part of the runtime?</p>]]></content:encoded>
	</item>
</channel>
</rss>
