<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Subjective C</title>
	<atom:link href="http://subjectivec.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://subjectivec.wordpress.com</link>
	<description>Learning the Objective-C ropes</description>
	<lastBuildDate>Sun, 30 Jan 2011 22:57:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='subjectivec.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Subjective C</title>
		<link>http://subjectivec.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://subjectivec.wordpress.com/osd.xml" title="Subjective C" />
	<atom:link rel='hub' href='http://subjectivec.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Update</title>
		<link>http://subjectivec.wordpress.com/2008/10/05/update/</link>
		<comments>http://subjectivec.wordpress.com/2008/10/05/update/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 03:31:03 +0000</pubDate>
		<dc:creator>nomothetis</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://subjectivec.wordpress.com/?p=17</guid>
		<description><![CDATA[Since I found out that people are actually reading this (much to my surprise), I feel Iowe you guys an update on what&#8217;s going on. I&#8217;ve scrapped the idea for IntelliTrack. Not that it&#8217;s a bad idea, but I&#8217;d like to make something semi-useful to me, and let&#8217;s face it, IntelliTrack is not it. Instead, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=17&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Since I found out that people are actually reading this (much to my surprise), I feel Iowe you guys an update on what&#8217;s going on.</p>
<p>
I&#8217;ve scrapped the idea for IntelliTrack. Not that it&#8217;s a bad idea, but I&#8217;d like to make something semi-useful to me, and let&#8217;s face it, IntelliTrack is not it. Instead, I&#8217;ve decided to make a simple issue tracker for Mac, as there doesn&#8217;t seem to be anything that a single developer can use to keep track of a pet project. I&#8217;ve toyed around with it already, spent the past few weeks trying to figure out how to create a sorted <tt>NSOutlineView</tt> (this was complicated by the fact that I was also figuring out Core Data), and now I think I&#8217;m ready to actually work on a prototype.</p>
<p>
I&#8217;ll post updates as they happen. Thanks for reading!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subjectivec.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subjectivec.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subjectivec.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subjectivec.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subjectivec.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subjectivec.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subjectivec.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subjectivec.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subjectivec.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subjectivec.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subjectivec.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subjectivec.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subjectivec.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subjectivec.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=17&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subjectivec.wordpress.com/2008/10/05/update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/486e697178ff4e2f7d97cd4da9bd5cc9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">nomothetis</media:title>
		</media:content>
	</item>
		<item>
		<title>Lesson learned: CoreData rocks.</title>
		<link>http://subjectivec.wordpress.com/2008/07/12/lesson-learned-coredata-rocks/</link>
		<comments>http://subjectivec.wordpress.com/2008/07/12/lesson-learned-coredata-rocks/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 00:04:53 +0000</pubDate>
		<dc:creator>nomothetis</dc:creator>
				<category><![CDATA[Model]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[CoreData]]></category>
		<category><![CDATA[fast development]]></category>
		<category><![CDATA[first time]]></category>
		<category><![CDATA[trial]]></category>

		<guid isPermaLink="false">http://subjectivec.wordpress.com/?p=14</guid>
		<description><![CDATA[I was going to be hardcore. I was going to define all my model classes in Objective-C, and I was going to create my object models, and link them to the interface, and be all proud of my working code. And I was going to ignore that pesky problem of persistence, because that was a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=14&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was going to be hardcore. I was going to define all my model classes in Objective-C, and I was going to create my object models, and link them to the interface, and be all proud of my working code. And I was going to ignore that pesky problem of persistence, because that was a different battle for another time.</p>
<p>And then I heard about CoreData. If you don&#8217;t know what it is, it&#8217;s basically a framework that gives you a way to model the persistent data of your application (the model part of MVC) via a very UML-like graphical notation, and then provides you with a unified and consistent way to access the data.</p>
<p>Don&#8217;t get me wrong, BTW. Though the graphical notation is UML-<em>like</em>, it&#8217;s not UML. It is strictly focused only on data content (and as such does not allow you to define methods, for example). In point of actual fact, it is based on the <a href="http://en.wikipedia.org/wiki/Entity-Attribute-Value_model">entity-attribute-value model</a> and as such is a database schema design modeling tool.</p>
<p>Still, after implementing my own quick data model shown below in about ten minutes, I was pretty pleased with CoreData. Okay, I admit it, myself too. But it&#8217;s really CoreData that should get the props.<br />
<div id="attachment_15" class="wp-caption alignnone" style="width: 310px"><a href="http://subjectivec.files.wordpress.com/2008/07/intellitrackdatamodel.png"><img src="http://subjectivec.files.wordpress.com/2008/07/intellitrackdatamodel.png?w=300&#038;h=236" alt="The IntelliTrack data model." width="300" height="236" class="size-medium wp-image-15" /></a><p class="wp-caption-text">The IntelliTrack data model.</p></div></p>
<p>The tricky part for me came when I tried to link the model to the application. I followed the instructions in the <a href="http://developer.apple.com/cocoa/coredatatutorial/index.html">CoreData video tutorial</a> slavishly, with a couple of exceptions:</p>
<ol>
<li> I had already created my application, and it wasn&#8217;t a CoreData Document-based application. It was a plain old application.
<li> I had a different plan for the UI.
</ol>
<p>I wasn&#8217;t too concerned about the second problem, since the whole point of MVC is that the UI should be pretty independent of your model. I stupidly didn&#8217;t even think about the second until, after trying to link my data to my model, I was greeted by an awkward error: my First Responder (as far as I can tell, the object that&#8217;s in charge of the application life cycle) did not respond to the <tt>managedObjectContext</tt> message. Oops.</p>
<p>The managed object context of an application, as explained <a href="http://developer.apple.com/macosx/coredata.html">here</a>, is the way the application accesses all the goodies defined in the model. Since I had not created my application as a CoreData application, my First Responder was completely unaware of the model.</p>
<p>In order to fix this problem, I cheated. I created a new project, made it a CoreData project, and compared the generated template code with my code. I basically copied over any files that were missing from my project (including the all-important delegate that did respond to <tt>managedObjectContext</tt>), and tried to link them as in the video. There were still a few differences, due to the fact that IntelliTrack is not document based (in other words, users won&#8217;t have a &#8220;myShipments.intelliTrack&#8221; file that gets saved), but for the most part is was smooth.</p>
<p>As a result, I now have an application that looks like this:</p>
<div id="attachment_16" class="wp-caption alignnone" style="width: 310px"><a href="http://subjectivec.files.wordpress.com/2008/07/intellitrack071108.png"><img src="http://subjectivec.files.wordpress.com/2008/07/intellitrack071108.png?w=300&#038;h=187" alt="IntelliTrack today!" width="300" height="187" class="size-medium wp-image-16" /></a><p class="wp-caption-text">IntelliTrack today!</p></div>
<p>And the best part? The &#8220;Add&#8221; button works, and the new items get persisted all on their own. All this in an evening&#8217;s worth of work. CoreData rocks.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/subjectivec.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/subjectivec.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subjectivec.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subjectivec.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subjectivec.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subjectivec.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subjectivec.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subjectivec.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subjectivec.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subjectivec.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subjectivec.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subjectivec.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subjectivec.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subjectivec.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subjectivec.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subjectivec.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=14&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subjectivec.wordpress.com/2008/07/12/lesson-learned-coredata-rocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/486e697178ff4e2f7d97cd4da9bd5cc9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">nomothetis</media:title>
		</media:content>

		<media:content url="http://subjectivec.files.wordpress.com/2008/07/intellitrackdatamodel.png?w=300" medium="image">
			<media:title type="html">The IntelliTrack data model.</media:title>
		</media:content>

		<media:content url="http://subjectivec.files.wordpress.com/2008/07/intellitrack071108.png?w=300" medium="image">
			<media:title type="html">IntelliTrack today!</media:title>
		</media:content>
	</item>
		<item>
		<title>False alarm</title>
		<link>http://subjectivec.wordpress.com/2008/07/09/false-alarm/</link>
		<comments>http://subjectivec.wordpress.com/2008/07/09/false-alarm/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 03:45:58 +0000</pubDate>
		<dc:creator>nomothetis</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[erratum]]></category>

		<guid isPermaLink="false">http://subjectivec.wordpress.com/?p=13</guid>
		<description><![CDATA[After playing a little bit, I realized that my toolbar did in fact work as &#8220;expected&#8221; (read: expected by an experienced OS X toolbar customizer). The problem I thought I had run into was that I couldn&#8217;t drag the new elements on the toolbar. Actually, I was trying to drag them onto the default toolbar [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=13&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After playing a little bit, I realized that my toolbar did in fact work as &#8220;expected&#8221; (read: expected by an experienced OS X toolbar customizer). </p>
<p>The problem I <em>thought</em> I had run into was that I couldn&#8217;t drag the new elements on the toolbar. Actually, I was trying to drag them onto the default toolbar (which appears in the sheet that is activated by the &#8220;Customize Toolbar&#8221; menu item).</p>
<p>What I actually had to do was drag the new items onto the actual toolbar of the application. My bad. Once I realized the error of my ways, all was well. So following the steps in the previous post should be enough to create a visually complete toolbar whose customization works as expected.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/subjectivec.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/subjectivec.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subjectivec.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subjectivec.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subjectivec.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subjectivec.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subjectivec.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subjectivec.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subjectivec.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subjectivec.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subjectivec.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subjectivec.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subjectivec.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subjectivec.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subjectivec.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subjectivec.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=13&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subjectivec.wordpress.com/2008/07/09/false-alarm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/486e697178ff4e2f7d97cd4da9bd5cc9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">nomothetis</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a Custom Cocoa Toolbar</title>
		<link>http://subjectivec.wordpress.com/2008/07/07/creating-a-custom-toolbar/</link>
		<comments>http://subjectivec.wordpress.com/2008/07/07/creating-a-custom-toolbar/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 01:01:35 +0000</pubDate>
		<dc:creator>nomothetis</dc:creator>
				<category><![CDATA[UI]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[NSToolbar]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://subjectivec.wordpress.com/?p=4</guid>
		<description><![CDATA[I&#8217;ve decided to learn Cocoa and Objective-C by creating a simple application for tracking shipments. The idea is that users will be able to enter shipments and their expected arrival date, and get a little alert from the application if the arrival date has passed and the shipment has not arrived. Simple stuff, I hope. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=4&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided to learn Cocoa and Objective-C by creating a simple application for tracking shipments. The idea is that users will be able to enter shipments and their expected arrival date, and get a little alert from the application if the arrival date has passed and the shipment has not arrived. Simple stuff, I hope. I&#8217;ll call it IntelliTrack. This will all be done in Xcode, because I cry when I don&#8217;t have Apple&#8217;s instructions on how to do things.</p>
<p>I began by creating a very basic application in Xcode. If you don&#8217;t know how to do that, working through <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/01Introduction/chapter_1_section_1.html">this tutorial</a> is very good to getting you started, and it&#8217;ll make following the rest of this easier. I basically don&#8217;t go over anything written there, since that tutorial is very self-contained.</p>
<p>With IntelliTrack set up in Xcode, I decided try to create a main window with a toolbar (easy) that has a search field (trouble).</p>
<p>I opened IntelliTrack/Resources/MainWindow.nib, which opened the UI of the application in <a href="http://developer.apple.com/tools/interfacebuilder.html" target="_blank">Interface Builder</a>. I selected an <tt>NSToolbar</tt> as the object to add from the library and dragged it onto the window title bar. This made the application window look like this:</p>
<div id="attachment_6" class="wp-caption alignnone" style="width: 310px"><a href="http://subjectivec.files.wordpress.com/2008/07/windowwithtoolbar.png"><img src="http://subjectivec.files.wordpress.com/2008/07/windowwithtoolbar.png?w=300&#038;h=277" alt="A window with the default Cocoa Toolbar" width="300" height="277" class="size-medium wp-image-6" /></a><p class="wp-caption-text">A window with the default Cocoa Toolbar</p></div>
<p>Nice for a few drag-and-drop actions, but there&#8217;s no search field there. Worse, there&#8217;s stuff I don&#8217;t need, like, well everything there. I wanted a toolbar that displays only the things I want it to display, and nothing more.</p>
<p>To find out how <tt>NSToolbar</tt>s work, I went <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/Toolbars/Concepts/HowToolbarsWork.html#//apple_ref/doc/uid/20000750">here</a>, and found out that toolbars have a certain default behavior that can be overridden by their delegate. Basically, a toolbar has a delegate that must implement three methods:</p>
<ol>
<li><tt><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSToolbar_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/toolbarAllowedItemIdentifiers:">toolbarAllowedItemIdentifiers</a></tt> returns the identifiers for the allowed items</li>
<li><tt><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSToolbar_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/toolbarDefaultItemIdentifiers:">toolbarDefaultItemIdentifiers</a></tt> returns the identifiers for the items that appear in the toolbar by default <em>if they are not overruled by the user preferences </em>.</li>
<li><tt><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSToolbar_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:">toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:</a></tt> returns the requested item.</li>
</ol>
<p>(Note that there are other delegate methods that can optionally be implemented, as described in the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSToolbar_Class/Reference/Reference.html">NSToolbar documentation</a>.)</p>
<p>Given that, I wanted a delegate that would:</p>
<ul>
<li> allow all the items that the default toolbar allows, as well as a custom search field</li>
<li> by default show only the search field, flush right.</li>
</ul>
<p>So, first things first, I created the delegate class. In Objective-C, that means I had to create a header file and an implementation file, the header file serving as the class&#8217; interface to the world. The code for the header file can be found <a href="http://pastebin.com/f47500afe">here</a>, with comments to explain how things work. The corresponding implementation is <a href="http://pastebin.com/f19b8058f">here</a>. These files reside in the IntelliTrack/Classes folder.</p>
<p><b>Fun facts</b>: </p>
<ul>
<li>Java and Ruby developers might notice that ITToolbarItemDelegate inherits from NSObject. NSObject is the equivalent in Cocoa of java.lang.Object or of Ruby&#8217;s root Object class. Inheritance must be explicitly stated because the compiler is not actually aware of the runtime. This bears repeating: the Objective-C language is separate from the Cocoa runtime provided by Apple. Objective-C simply provides a working syntax for calling objects (i.e., it will call the object you specify if it exists); it does not provide a root object to build from, or a set of libraries. In the (vaguely terrifying) words of the Cocoa documentation, if you wanted to, you <em>could</em> write your own root object&#8230;
<li>Java and Ruby developers might also notice that most variables are prefixed with an asterisk when they are declared. This means that the variables are pointers to a value, rather than the value itself. It essentially works the same way as a regular declaration in Java or Ruby. Variables that do not get the asterisk are the actual values themselves. This is unheard of in Java and Ruby-land, but don&#8217;t ask me to go into too much detail here, as I&#8217;m just learning this myself.
<li><tt>[NSArray arrayWithObjects:firstElement...]</tt> must have <tt>nil</tt> as its final parameter. No idea why; if someone could explain it, that would be great. I do know that if that convention is not followed, running the application gives a nasty EXC_BAD_ACCESS error.
</ul>
<p>At any rate, I had to remember to turn on garbage collection, and upon building, I was ready to finish the set up of the toolbar.</p>
<p>Three things remained to be done: create a search view, connect the toolbar to the toolbar delegate, and connect the toolbar delegate to the search view.</p>
<p>First, creating the search view is easy: I just dragged the NSSearchView from the library onto the MainMenu.nib window, and it appeared. For the toolbar delegate tasks, I imported the toolbar delegate by dragging an Object item from the library onto the window, and selecting ITToolbarDelegate as the class in the identity tab of its inspector. I then connected the <tt>searchToolbarItemView</tt> outlet (defined in ITTolbarDelegate.h) to the search view. Finally, I connected the toolbar&#8217;s <tt>delegate</tt> outlet to the toolbar delegate object in the window. At the end, the window looks like this (unfortunately, the connections are not visible):</p>
<div id="attachment_8" class="wp-caption alignnone" style="width: 303px"><a href="http://subjectivec.files.wordpress.com/2008/07/nibfile.png"><img src="http://subjectivec.files.wordpress.com/2008/07/nibfile.png?w=293&#038;h=300" alt="The MainMenu.nib file" width="293" height="300" class="size-medium wp-image-8" /></a><p class="wp-caption-text">The MainMenu.nib file</p></div>
<p>At last! It was ready to go. I compiled and ran (and debugged, and ran&#8230;) the application, expecting a nice toolbar with nothing but a search field. Instead, I got this:</p>
<div id="attachment_9" class="wp-caption alignnone" style="width: 310px"><a href="http://subjectivec.files.wordpress.com/2008/07/badtoolbar.png"><img src="http://subjectivec.files.wordpress.com/2008/07/badtoolbar.png?w=300&#038;h=277" alt="The actual result of all my efforts. Note the depressing plethora of items." width="300" height="277" class="size-medium wp-image-9" /></a><p class="wp-caption-text">The actual result of all my efforts. Note depressing plethora of items.</p></div>
<p>This despite the fact that the delegate method clearly returned only the flexible space and search items. The problem was that I hadn&#8217;t deleted the original items that appeared by default in the design view. As such, the toolbar thinks all those items are available (which is true) and to be displayed (which is not). It seems that the toolbar at this point either merges or concatenates the items that are displayed in the designer window with those that are returned from the delegate method, and shows the resulting set. After deleting the original items (this is done by double-clicking on the toolbar in the design view, and deleting all the items from the sheet that appears) and recompiling, I finally got the toolbar I was looking for:</p>
<div id="attachment_10" class="wp-caption alignnone" style="width: 310px"><a href="http://subjectivec.files.wordpress.com/2008/07/goodtoolbar.png"><img src="http://subjectivec.files.wordpress.com/2008/07/goodtoolbar.png?w=300&#038;h=273" alt="Triumph at last!" width="300" height="273" class="size-medium wp-image-10" /></a><p class="wp-caption-text">Triumph at last!</p></div>
<p>Unfortunately, some bugs remained, but I&#8217;ll go over those in a future post. Please feel free to leave any comments and corrections.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/subjectivec.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/subjectivec.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subjectivec.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subjectivec.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subjectivec.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subjectivec.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subjectivec.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subjectivec.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subjectivec.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subjectivec.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subjectivec.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subjectivec.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subjectivec.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subjectivec.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subjectivec.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subjectivec.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=4&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subjectivec.wordpress.com/2008/07/07/creating-a-custom-toolbar/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/486e697178ff4e2f7d97cd4da9bd5cc9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">nomothetis</media:title>
		</media:content>

		<media:content url="http://subjectivec.files.wordpress.com/2008/07/windowwithtoolbar.png?w=300" medium="image">
			<media:title type="html">A window with the default Cocoa Toolbar</media:title>
		</media:content>

		<media:content url="http://subjectivec.files.wordpress.com/2008/07/nibfile.png?w=293" medium="image">
			<media:title type="html">The MainMenu.nib file</media:title>
		</media:content>

		<media:content url="http://subjectivec.files.wordpress.com/2008/07/badtoolbar.png?w=300" medium="image">
			<media:title type="html">The actual result of all my efforts. Note the depressing plethora of items.</media:title>
		</media:content>

		<media:content url="http://subjectivec.files.wordpress.com/2008/07/goodtoolbar.png?w=300" medium="image">
			<media:title type="html">Triumph at last!</media:title>
		</media:content>
	</item>
		<item>
		<title>By way of introduction</title>
		<link>http://subjectivec.wordpress.com/2008/07/02/intro/</link>
		<comments>http://subjectivec.wordpress.com/2008/07/02/intro/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 22:33:46 +0000</pubDate>
		<dc:creator>nomothetis</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[This is a blog about my learning Objective-C. The Apple documentation (because let&#8217;s face it, I&#8217;m learning Obj-C because I want to create pretty Aqua UIs) claims you need to know C to learn objective C. Lies, I say! I will learn it with nothing but Java and Ruby under my belt! Please rubberneck here [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=1&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a blog about my learning Objective-C. The Apple documentation (because let&#8217;s face it, I&#8217;m learning Obj-C because I want to create pretty Aqua UIs) claims you need to know C to learn objective C. Lies, I say! I will learn it with nothing but Java and Ruby under my belt!</p>
<p>Please rubberneck here regularly.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/subjectivec.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/subjectivec.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/subjectivec.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/subjectivec.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/subjectivec.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/subjectivec.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/subjectivec.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/subjectivec.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/subjectivec.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/subjectivec.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/subjectivec.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/subjectivec.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/subjectivec.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/subjectivec.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/subjectivec.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/subjectivec.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=subjectivec.wordpress.com&amp;blog=4127952&amp;post=1&amp;subd=subjectivec&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://subjectivec.wordpress.com/2008/07/02/intro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/486e697178ff4e2f7d97cd4da9bd5cc9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">nomothetis</media:title>
		</media:content>
	</item>
	</channel>
</rss>
