<?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>Mac Fanatic &#187; Cocoa</title>
	<atom:link href="http://www.macfanatic.net/blog/category/cocoa/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.macfanatic.net/blog</link>
	<description>All Mac, All the Time</description>
	<lastBuildDate>Wed, 08 Feb 2012 21:46:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Interview with Cinder iPhone Developer Patrick Burleson</title>
		<link>http://www.macfanatic.net/blog/2010/03/08/interview-with-cinder-iphone-developer-patrick-burleson/</link>
		<comments>http://www.macfanatic.net/blog/2010/03/08/interview-with-cinder-iphone-developer-patrick-burleson/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 14:24:12 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2661</guid>
		<description><![CDATA[I recently wrote about BitBQ&#8217;s acquisition of LittleSnapper for iPhone, now Cinder, that was originally developed by Realmac software.  Being a very light LittleSnapper user myself, I was interested in who had taken interest in the application and wanted to get to know Patrick just a little better. He agreed to answer some questions I put together, [...]]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://www.macfanatic.net/blog/2010/03/03/littlesnapper-for-iphone-now-cinder/" target="_blank">recently wrote about BitBQ&#8217;s acquisition of LittleSnapper for iPhone</a>, now <a href="http://bitbq.com/cinder/" target="_blank">Cinder</a>, that was originally developed by <a href="http://www.realmacsoftware.com/" target="_blank">Realmac software</a>.  Being a very light LittleSnapper user myself, I was interested in who had taken interest in the application and wanted to get to know Patrick just a little better. He agreed to answer some questions I put together, including:</p>
<ul>
<li>Personal and company background</li>
<li>Talks about the Cinder acquisition</li>
<li>Talks about transferring an existing app from one company to another</li>
<li>Rates experience with Apple and the iTunes Store</li>
<li>Advertising tips</li>
<li>Gives his favorite Mac and iPhone apps</li>
</ul>
<p>Read after the break for Patrick&#8217;s answers.</p>
<p><span id="more-2661"></span></p>
<h2>&#8220;Please provide some general company background information&#8221;</h2>
<p>I started BitBQ back in August to be my company to create iPhone and Mac software. Since I started it up, I&#8217;ve acquired FitnessTrack, Emergency Information and LittleSnapper for iPhone (now Cinder). I did the acquisitions as a sort of kick start, but I have a couple of my own original apps in the works.</p>
<h2>&#8220;What is your personal expertise? Are you a software developer, business man, or something else entirely?”</h2>
<p>I&#8217;m a software developer, something I&#8217;ve been doing for over 14 years. Ranging from Perl to Java to .NET and of course Cocoa. Writing software is my passion and I love what the iPhone and Mac platforms provide in terms of feeding that passion.</p>
<h2>&#8220;What prompted the Cinder acquisition from Realmac Software?&#8221;</h2>
<p>It all started with a chat I was having with the original developer about what updates were planned for LittleSnapper for iPhone and learning they were looking to find someone who wanted to acquire it. As a user who loved LittleSnapper for iPhone, I jumped at the chance. We worked out the terms and as they say, the rest is history.</p>
<h2>&#8220;Do you personally use the ember web service?&#8221;</h2>
<p>Yes I do. I own LittleSnapper and now Cinder and use both to upload to Ember. I don&#8217;t use it as much as some people do, but I also can&#8217;t share a lot of the screenshots and other things I grab due to the sensitive nature of the images.</p>
<h2>&#8220;What exactly goes into transferring an application to another company, with Apple involved?&#8221;</h2>
<p>Having done this twice now, the dance is pretty simple: unless you have literally bought the entire company, there&#8217;s nothing Apple will do. You are forced to remove the original app and upload a brand new app. It can have the same name, once the original app has been removed. I had to do that with FitnessTrack.</p>
<p>What that means for users is that they have to be aware that the old app is going away and that there will be a new app showing up soon they&#8217;ll need to get to continue to receive updates. To alleviate some of the pain from this transition period, I&#8217;ve now tried two approaches. For FitnessTrack, I ran the app at 40% off on re-introduction to the app store and for Cinder, I&#8217;m running it for free for 2 weeks. The audience for Cinder is a lot larger considering the popularity of LittleSnapper for iPhone, so I wanted to make sure everyone has a chance to get it before I make it a paid app.</p>
<h2>&#8220;How would you rate your happiness with the iTunes App Store?&#8221;</h2>
<p>That&#8217;s a tough one. There are days I absolutely love it. I have Apple taking care of all the harder parts of software delivery: collecting payment, bandwidth, installation, etc. Then there are the days it&#8217;s infuriating. Like the current issue with Cinder not being able to be installed on iPod Touches because of a misconfiguration I can&#8217;t change on the back end without Apple&#8217;s intervention.</p>
<p>Of late, review times have dropped significantly, so that&#8217;s making me and a lot of other developers much happier. It&#8217;s still annoying when you have any hiccup in the process because the response delays are hard to put up with.</p>
<h2>&#8220;What, if any, advertising outlets have you used to promote your applications, and how would you rate those?&#8221;</h2>
<p>I ran a Fusion Ad for FitnessTrack just after the start of the new year. In conjunction with that ad run, I put FitnessTrack on sale for 40% off. While FitnessTrack certainly saw increased traffic and a slight increase in sales, they did not cover the cost of the ad. Before I did the ad, I got the advice of others that had run Fusion Ads and they warned me that it takes a long and sustained ad campaign to have any effect. I still considered it a net win just for the additional exposure to an larger audience. But I won&#8217;t be running any ads any time soon, so I&#8217;m going to have to find other ways to get the word out about my apps.</p>
<h2>&#8220;Are there any other applications you see now that you are thinking of acquiring?&#8221;</h2>
<p>I&#8217;ve been asked this by a few people. To be honest, the LittleSnapper for iPhone acquisition came as a total shock and I certainly wasn&#8217;t seeking it out. For my first acquisition, I did reach out to Justin Williams over at Second Gear to see if he was interested in selling his apps since I knew he was very frustrated with the whole App Store situation.</p>
<p>As of now, I don&#8217;t see any more app acquisition on the horizon for BitBQ. I&#8217;ve got a couple of apps in development, one for the iPhone and one for the Mac, that I&#8217;m planning on getting released this year. With that many apps, I&#8217;ve got a lot of work to keep me busy.</p>
<h2>&#8220;How long have you been using a Mac?&#8221;</h2>
<p>I first started using the Mac in 1992 on a Classic II in my journalism class. I quickly became the system administrator for the room full of Macs ( a mix of Classic IIs and SE/30s ). Those days, I was supporting System 7 and Pagemaker 4 back when it was owed by Aldus.</p>
<p>During my Mac &#8220;dark ages&#8221; (OS 9 till 10.3), I went off to work on Sun workstations and Windows machines. Once 10.4 Tiger hit, I could no longer resist coming back to the Mac. With my love of Unix and great software, the Mac was the place to be. It also helped that I could do any development I wanted on the machines. That was made even easier with the switch to Intel and the release of VMWare Fusion and Parallels. Now I didn&#8217;t even need to have Windows machines around. And I&#8217;m happy to say my house went back to Mac only in 2006.</p>
<h2>&#8220;What is your favorite Mac software application?&#8221;</h2>
<p>Wow, that&#8217;s a hard one to answer, I have so many favorites. How about a short list? <a href="http://nothirst.com/moneywell/" target="_blank">MoneyWell from No Thirst Software</a>, <a href="http://www.red-sweater.com/marsedit/" target="_blank">MarsEdit from Red Sweater Software</a>, <a href="http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html" target="_blank">SuperDuper! from Shirt Pocket Software</a>, <a href="http://www.secondgearsoftware.com/today/" target="_blank">Today from Second Gear</a>, <a href="http://www.rogueamoeba.com/pulsar/" target="_blank">Pulsar from Rouge Amoeba</a>, <a href="http://www.newsgator.com/individuals/netnewswire/" target="_blank">NetNewsWire from NewsGator</a>, <a href="http://getconcentrating.com/" target="_blank">Concentrate from Made By Rocket</a>, <a href="http://www.mcubedsw.com/software/codecollectorpro" target="_blank">Code Collector Pro from MCubed Software</a>, <a href="http://agilewebsolutions.com/products/1Password" target="_blank">1Password from Agile Web Solutions</a>, <a href="http://www.atebits.com/tweetie-mac/" target="_blank">Tweetie from Atebits</a>, <a href="http://www.panic.com/transmit/" target="_blank">Transmit from Panic</a>, and finally <a href="http://www.busymac.com/" target="_blank">BusyCal from BusyMac</a>.</p>
<p>Ok, so not such a short list, but a list of software I use daily outside of Apple&#8217;s apps. Every part of my day is made easier because of that list of software.</p>
<h2>&#8220;What is your favorite iPhone software application?&#8221;</h2>
<p>My favorite iPhone app is <a href="http://www.atebits.com/tweetie-iphone/" target="_blank">Tweetie 2</a>. It&#8217;s so well executed and has introduced so many awesome UI concepts. Beyond Mail, that&#8217;s the app I launch the most.</p>
<h2>Wrapping Up</h2>
<p>I want to thank Patrick for taking time out of his busy schedule to write up some excellent answers detailing a few questions I really was in the dark about.  Be sure to check out Cinder, for publishing to the wonderful web service Ember, now.  You can grab a free copy until March 17, 2010!</p>

<a href='http://www.macfanatic.net/blog/2010/03/08/interview-with-cinder-iphone-developer-patrick-burleson/cinder_accounts/' title='cinder_accounts'><img width="75" height="75" src="http://www.macfanatic.net/blog/wp-content/uploads/2010/03/cinder_accounts-150x150.png" class="attachment-thumbnail" alt="cinder_accounts" title="cinder_accounts" /></a>
<a href='http://www.macfanatic.net/blog/2010/03/08/interview-with-cinder-iphone-developer-patrick-burleson/cinder_home/' title='cinder_home'><img width="75" height="75" src="http://www.macfanatic.net/blog/wp-content/uploads/2010/03/cinder_home-150x150.png" class="attachment-thumbnail" alt="cinder_home" title="cinder_home" /></a>
<a href='http://www.macfanatic.net/blog/2010/03/08/interview-with-cinder-iphone-developer-patrick-burleson/cinder_share_menu/' title='cinder_share_menu'><img width="75" height="75" src="http://www.macfanatic.net/blog/wp-content/uploads/2010/03/cinder_share_menu-150x150.png" class="attachment-thumbnail" alt="cinder_share_menu" title="cinder_share_menu" /></a>
<a href='http://www.macfanatic.net/blog/2010/03/08/interview-with-cinder-iphone-developer-patrick-burleson/cinder_snap_info/' title='cinder_snap_info'><img width="75" height="75" src="http://www.macfanatic.net/blog/wp-content/uploads/2010/03/cinder_snap_info-150x150.png" class="attachment-thumbnail" alt="cinder_snap_info" title="cinder_snap_info" /></a>

<p>&nbsp;</p>
<h2>Links</h2>
<div><a href="http://bitbq.com/cinder/buy.html" target="_blank">Cinder iPhone App</a> [iTunes Store Link]</div>
<div><a href="http://bitbq.com/cinder/" target="_blank">BitBQ Website</a></div>
<div><a href="http://www.realmacsoftware.com/" target="_blank">Realmac Software</a></div>
<div><a href="http://emberapp.com/" target="_blank">Ember Web Service</a></div>
<div><a href="http://twitter.com/CinderApp" target="_blank">Follow Cinder App</a> [Twitter]</div>
<div><a href="http://twitter.com/emberapp" target="_blank">Follow Ember </a>[Twitter]</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/03/08/interview-with-cinder-iphone-developer-patrick-burleson/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>That&#8217;s What She Said Jokes 1.0.1 Now Available</title>
		<link>http://www.macfanatic.net/blog/2010/02/19/thats-what-she-said-jokes-1-0-1-now-available/</link>
		<comments>http://www.macfanatic.net/blog/2010/02/19/thats-what-she-said-jokes-1-0-1-now-available/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 14:12:40 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[That's What She Said Jokes]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2592</guid>
		<description><![CDATA[I&#8217;d like to first thank everyone who has purchased a copy of That&#8217;s What She Said Jokes from the iTunes App Store this week, it&#8217;s been a great launch week.  And an even bigger thanks to those who have registered and submitted their own jokes! Version 1.0.1 is now available in the iTunes App Store [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to first thank everyone who has purchased a copy of That&#8217;s What She Said Jokes from the iTunes App Store this week, it&#8217;s been a great launch week.  And an even bigger thanks to those who have registered and submitted their own jokes!</p>
<p>Version 1.0.1 is now available in the iTunes App Store and offers the following new features and fixes:</p>
<ul>
<li>NEW: Up/Down buttons for quicker navigation while already viewing a joke, like in Mail.app</li>
<li>NEW: User names are displayed, crediting who ever submitted the joke</li>
<li>FIXED: Better support for landscape mode</li>
<li>FIXED: Improved and more informative user alerts</li>
<li>FIXED: Fixed keyboard issue when submitting a new entry</li>
<li>FIXED: If there is an error submitting an entry, user now has opportunity to copy the text to use later</li>
<li>FIXED: Interface tweaks</li>
</ul>
<p>I&#8217;ve had a great time developing the application and have a few awesome features in the pipeline.  I&#8217;d love to hear what you would like to see in a future update, and by all means, submit your own funny moments and rate the existing ones!</p>
<p>Grab your copy of That&#8217;s What She Said Jokes for 0.99 cents now [<a href="http://itunes.apple.com/us/app/thats-what-she-said-jokes/id354904787?mt=8" target="_blank">App Store Link</a>].</p>
<p>Be sure to check out the That&#8217;s What She Said Jokes website as well, at<a href="http://twss.macfanatic.net"> http://twss.macfanatic.net</a></p>

<a href='http://www.macfanatic.net/blog/2010/02/19/thats-what-she-said-jokes-1-0-1-now-available/reviews/' title='reviews'><img width="75" height="75" src="http://www.macfanatic.net/blog/wp-content/uploads/2010/02/reviews-150x150.png" class="attachment-thumbnail" alt="reviews" title="reviews" /></a>
<a href='http://www.macfanatic.net/blog/2010/02/19/thats-what-she-said-jokes-1-0-1-now-available/submit/' title='submit'><img width="75" height="75" src="http://www.macfanatic.net/blog/wp-content/uploads/2010/02/submit-150x150.jpg" class="attachment-thumbnail" alt="submit" title="submit" /></a>
<a href='http://www.macfanatic.net/blog/2010/02/19/thats-what-she-said-jokes-1-0-1-now-available/recents/' title='recents'><img width="75" height="75" src="http://www.macfanatic.net/blog/wp-content/uploads/2010/02/recents-150x150.jpg" class="attachment-thumbnail" alt="recents" title="recents" /></a>
<a href='http://www.macfanatic.net/blog/2010/02/19/thats-what-she-said-jokes-1-0-1-now-available/reading/' title='reading'><img width="75" height="75" src="http://www.macfanatic.net/blog/wp-content/uploads/2010/02/reading-150x150.jpg" class="attachment-thumbnail" alt="reading" title="reading" /></a>

]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/02/19/thats-what-she-said-jokes-1-0-1-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EMKeychain 1.0 Released</title>
		<link>http://www.macfanatic.net/blog/2010/02/04/emkeychain-1-0-released/</link>
		<comments>http://www.macfanatic.net/blog/2010/02/04/emkeychain-1-0-released/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 18:32:13 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2510</guid>
		<description><![CDATA[EMKeychain is a Cocoa class-wrapper  for viewing and modifying the Mac OS X Keychain. Very simple interface and would be a great addition to any developer&#8217;s toolkit.  From ExtendedMac Software: EMKeychain v1.0 is now available. With it comes the following changes: Re-written for Objective-C 2.0 features, like properties. Ability to remove a keychain item. Streamlined [...]]]></description>
			<content:encoded><![CDATA[<p>EMKeychain is a Cocoa class-wrapper  for viewing and modifying the Mac OS X Keychain.</p>
<p>Very simple interface and would be a great addition to any developer&#8217;s toolkit.  From ExtendedMac Software:</p>
<p>EMKeychain v1.0 is now available. With it comes the following changes:</p>
<blockquote>
<ul>
<li>Re-written for Objective-C 2.0 features, like properties.</li>
<li>Ability to remove a keychain item.</li>
<li>Streamlined design — no more proxy!</li>
<li>Fixes for memory leaks and other bugs.</li>
<li>Complete <a href="http://extendmac.com/EMKeychain/Documentation">documentation</a>.</li>
</ul>
</blockquote>
<p>Check out the ExtendedMac article <a href="http://extendmac.com/blog/2010/02/emkeychain-1-0-now-available/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/02/04/emkeychain-1-0-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CLAlert Class</title>
		<link>http://www.macfanatic.net/blog/2009/12/23/2157/</link>
		<comments>http://www.macfanatic.net/blog/2009/12/23/2157/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 00:03:11 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2157</guid>
		<description><![CDATA[If you&#8217;ve ever used NSAlert in your Cocoa application and wondered why NSInformationalAlertStyle and NSWarningAlertStyle looked exactly the same when using NSAlert, you&#8217;re not the only one.  CLAlert has been released (MIT license) that uses an information bubble for NSInformationalAlertStyle, caution icon (currently NSCriticalAlertStyle) for NSWarningAlertStyle, and a red stop sign for NSCriticalAlertStyle. Makes much more sense [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever used NSAlert in your Cocoa application and wondered why NSInformationalAlertStyle and NSWarningAlertStyle looked exactly the same when using NSAlert, you&#8217;re not the only one.  CLAlert has been released (MIT license) that uses an information bubble for NSInformationalAlertStyle, caution icon (currently NSCriticalAlertStyle) for NSWarningAlertStyle, and a red stop sign for NSCriticalAlertStyle.</p>
<p>Makes much more sense from a UI perspective.  Check out CLAlert <a href="http://0xced.blogspot.com/2009/11/clalert-nsalert-done-right.html" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/12/23/2157/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSFileManager Additions</title>
		<link>http://www.macfanatic.net/blog/2009/12/05/nsfilemanager-additions/</link>
		<comments>http://www.macfanatic.net/blog/2009/12/05/nsfilemanager-additions/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 14:45:46 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1880</guid>
		<description><![CDATA[Continuing with providing useful Cocoa snippets, I have posted a few NSFileManager category methods to help easily determine the file size of a single file, directory, or quickly hide a file/directory using the invisibility bit (like using /usr/bin/setfile, ie: setfile -a V somefile). 1 2 3 4 5 @interface NSFileManager &#40;MacFanatic&#41; - &#40;unsigned long&#41; sizeOfDirectory:&#40;NSString*&#41;dir; [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing with providing useful Cocoa snippets, I have posted a few NSFileManager category methods to help easily determine the file size of a single file, directory, or quickly hide a file/directory using the invisibility bit (like using /usr/bin/setfile, ie:  setfile -a V somefile).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> <span style="color: #400080;">NSFileManager</span> <span style="color: #002200;">&#40;</span>MacFanatic<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">long</span><span style="color: #002200;">&#41;</span> sizeOfDirectory<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>dir;	<span style="color: #11740a; font-style: italic;">// Bytes</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">long</span><span style="color: #002200;">&#41;</span> sizeOfFile<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>file;		<span style="color: #11740a; font-style: italic;">// Bytes</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>setInvisibilityFlag<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>invisible forPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">long</span><span style="color: #002200;">&#41;</span> sizeOfDirectory<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>dir <span style="color: #002200;">&#123;</span>
&nbsp;
	<span style="color: #400080;">NSAutoreleasePool</span> <span style="color: #002200;">*</span>pool <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSAutoreleasePool</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSFileManager</span><span style="color: #002200;">*</span> manager <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSFileManager</span> defaultManager<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">unsigned</span> <span style="color: #a61390;">long</span> size <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
	<span style="color: #400080;">NSDirectoryEnumerator</span> <span style="color: #002200;">*</span>e <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>manager enumeratorAtPath<span style="color: #002200;">:</span>dir<span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> file <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
&nbsp;
	<span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span> file <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>e nextObject<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		size <span style="color: #002200;">+=</span> <span style="color: #002200;">&#91;</span>manager sizeOfFile<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>dir stringByAppendingPathComponent<span style="color: #002200;">:</span>file<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #002200;">&#91;</span>pool release<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">return</span> size;
&nbsp;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<h2 style="margin-top:40px">Download</h2>
<p class="download">Be sure to download a <a href="http://www.macfanatic.net/downloads/software/samplecode/NSFileManager-Additions.zip">zip of the .h and .m files</a> (10.4+)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/12/05/nsfilemanager-additions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add Application to Dock &#8211; Cocoa NSApplication Category</title>
		<link>http://www.macfanatic.net/blog/2009/12/02/add-application-to-dock-cocoa-nsapplication-category/</link>
		<comments>http://www.macfanatic.net/blog/2009/12/02/add-application-to-dock-cocoa-nsapplication-category/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 14:00:50 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1823</guid>
		<description><![CDATA[The need to quickly add my application to a user&#8217;s Dock arose while working on a project for a client a few months back.  I was intrigued by the code (first encounter with NSAppleScript as the big one) and took some time to sit down and refine what I had originally pieced together into something [...]]]></description>
			<content:encoded><![CDATA[<p>The need to quickly add my application to a user&#8217;s Dock arose while working on a project for a client a few months back.  I was intrigued by the code (first encounter with NSAppleScript as the big one) and took some time to sit down and refine what I had originally pieced together into something more usable.</p>
<p>What I eventually settled upon was writing a few category methods for NSApplication, allowing you to easily check and see if your app is already in the user&#8217;s Dock, or add your application to the users Dock (doesn&#8217;t allow for precise placement).</p>
<p>NSApplication-MacFanatic.h adds the following 4 methods:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> <span style="color: #400080;">NSApplication</span> <span style="color: #002200;">&#40;</span>MacFanatic<span style="color: #002200;">&#41;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>addApplicationToDock;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>applicationExistsInDock;
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>addApplicationToDock<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>applicationExistsInDock<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<h2 style="margin-top:40px">Examples</h2>
<hr />To quickly see if your application is in the user&#8217;s Dock:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSApplication</span> sharedApplication<span style="color: #002200;">&#93;</span> applicationExistsInDock<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// App is in dock</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>To quickly add your application to the user&#8217;s Dock:</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;">NSApplication</span> sharedApplication<span style="color: #002200;">&#93;</span> addApplicationToDock<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>These first two methods should undoubtedly come in handy, but as I was originally writing an installer and needed to add the application I was installing, not the currently running application (the installer), to the Dock, so there are yet two more methods for checking a specific application by passing a path.</p>
<p>Checking to see if Atlas is in the user&#8217;s Dock:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSApplication</span> sharedApplication<span style="color: #002200;">&#93;</span> applicationExistsInDock<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;/Applications/Atlas.app&quot;</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// Atlas is in dock</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Adding Atlas to the user&#8217;s Dock:</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;">NSApplication</span> sharedApplication<span style="color: #002200;">&#93;</span> addApplicationToDock<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;/Applications/Atlas.app&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<h2 style="margin-top:40px">Inner Workings</h2>
<p>Here&#8217;s a quick peak at the method for determining if the application is currently in the user&#8217;s Dock:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>44
45
46
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span> applicationExistsInDock <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>self applicationExistsInDock<span style="color: #002200;">:</span><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> bundlePath<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span> applicationExistsInDock<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path <span style="color: #002200;">&#123;</span>
&nbsp;
	<span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> app <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
&nbsp;
	<span style="color: #400080;">NSUserDefaults</span> <span style="color: #002200;">*</span> defaults <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSUserDefaults</span> standardUserDefaults<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>defaults addSuiteNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;com.apple.Dock&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #400080;">NSArray</span><span style="color: #002200;">*</span> apps <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>defaults objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;persistent-apps&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> <span style="color: #400080;">NSDictionary</span><span style="color: #002200;">*</span> d <span style="color: #a61390;">in</span> apps <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		app <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>d objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;tile-data&quot;</span><span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;file-data&quot;</span><span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;_CFURLString&quot;</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span>app isEqualToString<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<h2 style="margin-top:40px">Some Notes</h2>
<p>All of these methods are based on absolute paths &#8211; not application identifiers.  So if the user is running your application from the Desktop and has an alias to your application in the /Applications folder, it will return false.  Doesn&#8217;t matter that the user has two copies of your application.</p>
<p>Love to get some feedback on this, it&#8217;s my finest code contribution on the blog to date I believe.  I&#8217;ve refined this a good bit, but it could use some more love I&#8217;m sure.  I hope to hear that someone has used this in a project!</p>
<h2 style="margin-top:40px">Updates</h2>
<p>This was marked as Tiger compatible code, but I noticed I&#8217;m using Fast Iteration, which was introduced in Leopard.  For Tiger compatibility, just change a few lines:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span> applicationExistsInDock<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path <span style="color: #002200;">&#123;</span>
&nbsp;
	<span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> app <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
&nbsp;
	<span style="color: #400080;">NSUserDefaults</span> <span style="color: #002200;">*</span> defaults <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSUserDefaults</span> standardUserDefaults<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>defaults addSuiteNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;com.apple.Dock&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #400080;">NSArray</span><span style="color: #002200;">*</span> apps <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>defaults objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;persistent-apps&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSDictionary</span><span style="color: #002200;">*</span> d <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
	<span style="color: #400080;">NSEnumerator</span><span style="color: #002200;">*</span> e <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>apps objectEnumerator<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span> d <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>e nextObject<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		app <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>d objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;tile-data&quot;</span><span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;file-data&quot;</span><span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;_CFURLString&quot;</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span>app isEqualToString<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>The download has been updated to contain the new code.</p>
<h2 style="margin-top:40px">Downloads</h2>
<p class="download">Grab the .h and .m files in <a href="/downloads/software/samplecode/NSApplication-Additions.zip">this zip (10.4+)</a></p>
<p class="download">Example <a href="/downloads/software/samplecode/Add-to-Dock.zip">Xcode project (Xcode 3.2, 10.6+)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/12/02/add-application-to-dock-cocoa-nsapplication-category/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Grand Central Dispatch &#8211; Source Posted on MacOSForge</title>
		<link>http://www.macfanatic.net/blog/2009/09/11/grand-central-dispatch-source-posted-on-macosforge/</link>
		<comments>http://www.macfanatic.net/blog/2009/09/11/grand-central-dispatch-source-posted-on-macosforge/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 13:35:55 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1581</guid>
		<description><![CDATA[Grand Central Dispatch, introduced in Snow Leopard, brings a C API for effectively managing concurrency in your applications. Apple has now posted the code for the user space implementation online at MacOSForge. The kernel optimizations are linked in the project page, but the API only requires a C compiler supporting Blocks, such as the LLVM [...]]]></description>
			<content:encoded><![CDATA[<p>Grand Central Dispatch, introduced in Snow Leopard, brings a C API for effectively managing concurrency in your applications.  Apple has now posted the code for the user space implementation online at MacOSForge.  The kernel optimizations are linked in the project page, but the API only requires a C compiler supporting Blocks, such as the LLVM compiler.</p>
<p><a target="_blank" href="http://en.wikipedia.org/wiki/Grand_Central_Dispatch">Grand Central Dispatch &#8211; Wiki</a><br />
<a target="_blank" href="http://www.apple.com/macosx/technology/">Grand Central Dispatch &#8211; Apple</a><br />
<a target="_blank" href="http://libdispatch.macosforge.org/">Grand Central Dispatch &#8211; MacOSForge</a><br />
<a target="_blank" href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html">Blocks Programming Guide &#8211; Apple</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/09/11/grand-central-dispatch-source-posted-on-macosforge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Compiling for Tiger on Snow Leopard</title>
		<link>http://www.macfanatic.net/blog/2009/09/02/quick-tip-compiling-for-tiger-on-snow-leopard/</link>
		<comments>http://www.macfanatic.net/blog/2009/09/02/quick-tip-compiling-for-tiger-on-snow-leopard/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 17:15:45 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1511</guid>
		<description><![CDATA[Just to save someone 3-5 minutes of time, if you install the 10.4u SDK to target Tiger machines with Xcode 3.2 (Snow Leopard), you will have to change a build setting to get Xcode to compile. In the settings for your target, change the compiler option from &#8220;System Default &#8211; GCC 4.2&#8243; to &#8220;GCC 4.0&#8243;. [...]]]></description>
			<content:encoded><![CDATA[<p>Just to save someone 3-5 minutes of time, if you install the 10.4u SDK to target Tiger machines with Xcode 3.2 (Snow Leopard), you will have to change a build setting to get Xcode to compile.</p>
<p>In the settings for your target, change the compiler option from &#8220;System Default &#8211; GCC 4.2&#8243; to &#8220;GCC 4.0&#8243;.  Then the error message will go away and you can build for Tiger.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/09/02/quick-tip-compiling-for-tiger-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Snow Leopard Review</title>
		<link>http://www.macfanatic.net/blog/2009/09/02/ars-technica-snow-leopard-review/</link>
		<comments>http://www.macfanatic.net/blog/2009/09/02/ars-technica-snow-leopard-review/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 12:00:20 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1516</guid>
		<description><![CDATA[I thought I would highlight what I found to be the most interesting points from the Snow Leopard Ars Technica review, for those who couldn&#8217;t make it through the 23 page review and provide a few thoughts on the OS overall. Read after the break for a list of UI and usability changes as well [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I would highlight what I found to be the most interesting points from the <a title="View the &quot;Ars Technica Snow Leopard Review&quot;" href="http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars" target="_blank">Snow Leopard Ars Technica </a>review, for those who couldn&#8217;t make it through the 23 page review and provide a few thoughts on the OS overall.</p>
<p>Read after the break for a list of UI and usability changes as well as a list of interesting changes for Cocoa developers, including code samples.</p>
<p><a title="View the &quot;Ars Technica Snow Leopard Review&quot;" href="http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars" target="_blank"><img class="alignnone size-full wp-image-1517" style="margin:25px; 0px 25px 18px;" title="Snow Leopard Ars Technica Review" src="http://www.macfanatic.net/blog/wp-content/uploads/2009/09/snow_leopard_ars-thumb-640xauto-8029.jpg" alt="Snow Leopard Ars Technica Review" /></a></p>
<p><span id="more-1516"></span></p>
<h1>User Centric Thoughts</h1>
<hr />Through the first half of this article, I&#8217;ll focus on user interface changes and just general usability improvements in the OS.</p>
<h2>Dock</h2>
<p>There were several changes to the Dock, but the one I found the most interesting (and didn&#8217;t know before reading) was the &#8220;Minimize windows into the application icon&#8221; option.  Instead of little windows appearing in the Dock, when clicking the application icon you are shown a list of minimized windows.  Very reminiscent of Windows and the task bar (as there is no preview, only the window title), but surely useful for those out there who minimize lots of windows.</p>
<h2>Finder</h2>
<p>The Finder was completely rewritten for Snow Leopard and should provide a strong foundation moving forward.  There is heavy use of Core Animation in the new Finder, meaning that it just &#8220;looks prettier&#8221; most of the time.  There are animations when renaming files on your Desktop for instance.  And a feature that I personally love:</p>
<blockquote><p>List view also has a few enhancements—accidental, incidental, or otherwise. The drag area for each list view item now spans the entire line. In Leopard, though the entire line was highlighted, only the file name or icon portion could be dragged. Trying to drag anywhere else just extended the selection to other items in the list view as the cursor was moved. I&#8217;m not sure whether this change in behavior is intentional or if it&#8217;s just an unexamined consequence of the underlying control used for list view in the new Cocoa Finder. Either way, thumbs up.</p></blockquote>
<p>Overall the Finder looks very similar to the Leopard version, but is more responsive and has a feature here and there that reminds you that this is a new version.</p>
<h2>Radnom Refinements</h2>
<p>This is just an assortment of interesting tidbits I picked up while reading.</p>
<ul>
<li>Safari runs plugins as separate processes. If a plugin crashes, Safari won&#8217;t.</li>
<li>Menlo is the new default font for Monospaced fonts (S<a href="http://www.macfanatic.net/blog/2009/06/15/programming-fonts/">ee my article here</a>)</li>
<li>Resolution Independence still sucks</li>
<li>Core Location support &#8211; your Mac can find itself</li>
<li>Wake from Sleep feature &#8211; with a Time Capsule or AirPort Extreme station, you can access contents from a sleeping Mac over the local network at any time.  Works great with the &#8220;Back to my Mac&#8221; feature.</li>
<li>No <a href="http://en.wikipedia.org/wiki/ZFS" target="_blank">ZFS</a> support</li>
</ul>
<h1 style="margin-top:45px;">Developer Centric Thoughts</h1>
<hr />Here on out is several points of interest for developers.</p>
<h2>File Compression</h2>
<p>Snow Leopard introduces per file compression to the HFS+ file system used by Apple.</p>
<h3>Resource Forks &amp; Extended File Attributes</h3>
<p>To bring file compression to the already fragile HFS+ file system and maintain backwards compatibility, Apple stores the compressed file data in resource forks, and either compressed or uncompressed in extended file attributes.  What this means:</p>
<blockquote><p>And where can the complete contents of a potentially large file be hidden in such a way that pre-Snow Leopard systems can still copy that file without the loss of data? Why, in the resource fork, of course. The Finder has always correctly preserved Mac-specific metadata and both the resource and data forks when moving or duplicating files. In Leopard, even the lowly cp and rsync commands will do the same. So while it may be a little bit spooky to see all those &#8220;empty&#8221; 0 KB files when looking at a Snow Leopard disk from a pre-Snow Leopard OS, the chance of data loss is small, even if you move or copy one of the files.</p></blockquote>
<h3>Performance Gains</h3>
<p>You might first think that all this file compression would either waste space or waste CPU cycles.  John from Ars Technica proposes that given the known fact that the physical motions of a hard drive are the slowest part of modern computers, storing the compressed data in resource forks and extended attributes makes sense because that data is stored in one of two locations on the disk.  And because these two areas are frequently used, the read/write head of the hard drive is close by and has less moves to make and can be quicker.  Also, because the two files are accessed so frequently, caching occurs providing even greater performance benefits.</p>
<h2>QuickTime X</h2>
<p>Snow Leopard introduced a completely rewritten 64-bit API for QuickTime.  The new QuickTime X Player is nice and fancy, but the underlying API has underwent the knife.  QuickTime debuted in 1991 and after 18 years has finally seen a significant update.</p>
<h3>64 Bit</h3>
<p>The interesting part is the new QuickTime X API in QTKit is smart.  The API is optimized for playback and is 64 bit only.  Transparently, if an application needs features that QTKit (QuickTime X) cannot deliver (and there are many currently), QTKit will revert to the previous QuickTime 7 API.  And if a developer writes a 32 bit application and wants to use the newer QuickTime X API, QTkit will just spawn another process that is 64 bit to deliver content back to the 32 bit application, all transparently. The user will get the best experience with the least amount of effort from the developer, which is always a win.</p>
<h2>File System API Unification</h2>
<p>Briefly, between POSIX functions, CoreFoundation, and Cocoa itself, there are several ways to access data about the filesystem.  Currently there is no unified approach to fetch all this data.</p>
<p>When opening a file in Leopard Preview, there are:</p>
<blockquote>
<ul>
<li>Four conversions of an FSRef to a file path</li>
<li>Ten conversions of a file path to an FSRef</li>
<li>Twenty-five calls to getattrlist()</li>
<li>Eight calls to stat()/lstat()</li>
<li>Four calls to open()/close()</li>
</ul>
</blockquote>
<p>Snow Leopard will use NSURL for all file system operations, instead of strings representing file paths.  To the end user, this means the user could move a file and the application wouldn&#8217;t lose track of it as the NSURL has a unique identifier that is not based on file location alone.</p>
<h2>Clang and LLVM</h2>
<h3>Performance Gains</h3>
<blockquote><p>Clang brings with it the two headline attributes you expect in a hot, new compiler: shorter compile times and faster executables. In Apple&#8217;s testing with its own applications such as iCal, Address Book, and Xcode itself, plus third-party applications like Adium and Growl, Clang compiles nearly three times faster than GCC 4.2. As for the speed of the finished product, the LLVM back-end, whether used in Clang or in LLVM-GCC, produces executables that are 5-25% faster than those generated by GCC 4.2.</p></blockquote>
<h3>Static Analyzer</h3>
<p>The static analyzer is the single best feature in Snow Leopard as far as I&#8217;m concerned.  Essentially Xcode is smarter and can analyze all ways your code might interact to determine errors in your logic.  Unprecedented.</p>
<p>Read more about my thoughts on the static analyzer in Xcode 3.2 <a href="http://www.macfanatic.net/blog/2009/08/28/xcode-3-2-static-analysis/">here</a>.</p>
<h2>Blocks</h2>
<p>Blocks are an extension to C based languages, currently only supported by Apple in it&#8217;s 4 compilers shipping with Snow Leopard.  Essentially, blocks are a way to pass a &#8220;block&#8221; of code.  Not the same as a function, which has it&#8217;s own scope.</p>
<h3>Example</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">FILE</span> <span style="color: #002200;">*</span>fp <span style="color: #002200;">=</span> <span style="color: #a61390;">fopen</span><span style="color: #002200;">&#40;</span>filename, <span style="color: #bf1d1a;">&quot;r&quot;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>fp <span style="color: #002200;">==</span> <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
  <span style="color: #a61390;">perror</span><span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;Unable to open file&quot;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
  <span style="color: #a61390;">char</span> line<span style="color: #002200;">&#91;</span>MAX_LINE<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">fgets</span><span style="color: #002200;">&#40;</span>line, MAX_LINE, fp<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    work;
    work;
    work;
  <span style="color: #002200;">&#125;</span>
&nbsp;
  <span style="color: #a61390;">fclose</span><span style="color: #002200;">&#40;</span>fp<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>The example above is boilerplate code and assumes you want to do some &#8220;work;&#8221; with the line once you&#8217;ve read it in from a file.  By using blocks, you could create a function that takes the filename and a block, simplifying moving through the file greatly.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">foreach_line<span style="color: #002200;">&#40;</span>filename, <span style="color: #002200;">^</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">char</span> <span style="color: #002200;">*</span>line<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
  work;
  work;
  work;
<span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;</pre></div></div>

<h3>API Use</h3>
<p>John informs us that Apple uses blocks in over 100 new API calls that would simply not be possible prior to Snow Leopard.</p>
<h2>Threading and Grand Central Dispatch</h2>
<p>The age old problem in computing:</p>
<blockquote><p>This is the enemy: hardware with more computing resources than programmers know what to do with, most of it completely idle, and all the while the user is utterly blocked in his attempts to use the current application.</p></blockquote>
<p>Grand Central Dispatch makes great progress in helping developers alleviate the headaches in asynchronously executing tasks in their application.</p>
<h3>Overview</h3>
<p>Essentially, Grand Central Dispatch (GCD) is a system level library that manages a global pool of available threads, and grabs tasks from queues your application sets up.  The more resources the system has available, the more threads GCD has free and the faster it can grab tasks from your application queues.  Since the system is managing the threads, there is no application overhead for thread management and the possibility of too many threads, and yet your application can get the last bit of performance from the system by using all available resources.  All automatically.</p>
<blockquote><p>Let&#8217;s say a program has a problem that can be split into eight separate, independent units of work. If this program then creates four threads on an eight-core machine, is this an example of creating too many or too few threads? Trick question! The answer is that it depends on what else is happening on the system.</p>
<p>If six of the eight cores are totally saturated doing some other work, then creating four threads will just require the OS to waste time rotating those four threads through the two available cores. But wait, what if the process that was saturating those six cores finishes? Now there are eight available cores but only four threads, leaving half the cores idle.</p></blockquote>
<p>There is a performance gain here is as well.  If you were managing threads at your application level, you have to create and release threads as you use them.  GCD uses a global thread pool, so the threads are always active.  Whether or not they are working is the only change.  By simply maintaining active threads, the system can pull just a little bit more performance from the system.</p>
<h3>First Example</h3>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span>analyzeDocument<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSButton</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sender
<span style="color: #002200;">&#123;</span>
  <span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>stats <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>myDoc analyze<span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>myModel setDict<span style="color: #002200;">:</span>stats<span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>myStatsView setNeedsDisplay<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>stats release<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>The above method is a simple action called by a button click that will analyze a document and display the results.  Under normal circumstances this would be nearly instantaneous.  However, if a user attempted to analyze a very large document, the processing still takes place on the main event processing thread and the application appears to hang.  Refactoring this to use threads and avoid race conditions, with callbacks for analyzeComplete would be a mess and most developers would balk at the trouble to make this four line method asynchronous.  However, with GCD and Blocks, it becomes trivial.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span>analyzeDocument<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSButton</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sender
<span style="color: #002200;">&#123;</span>
  dispatch_async<span style="color: #002200;">&#40;</span>dispatch_get_global_queue<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>, <span style="color: #002200;">^</span><span style="color: #002200;">&#123;</span>
    <span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>stats <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>myDoc analyze<span style="color: #002200;">&#93;</span>;
    dispatch_async<span style="color: #002200;">&#40;</span>dispatch_get_main_queue<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>, <span style="color: #002200;">^</span><span style="color: #002200;">&#123;</span>
      <span style="color: #002200;">&#91;</span>myModel setDict<span style="color: #002200;">:</span>stats<span style="color: #002200;">&#93;</span>;
      <span style="color: #002200;">&#91;</span>myStatsView setNeedsDisplay<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
      <span style="color: #002200;">&#91;</span>stats release<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;
  <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Now when the user clicks the &#8220;Analyze&#8221; button, a block is placed on the application queue to be processed as soon as possible.  This block analyzes the document, and once that is complete, the block placed onto the event queue with &#8221; dispatch_async()&#8221; will be called, therefore updating the UI.  Simply wonderful.</p>
<h3>Second Example</h3>
<p>Here is a truly gorgeous example from John.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i <span style="color: #002200;">&amp;</span>lt; count; i<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    results<span style="color: #002200;">&#91;</span>i<span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> do_work<span style="color: #002200;">&#40;</span>data, i<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span> 
&nbsp;
total <span style="color: #002200;">=</span> summarize<span style="color: #002200;">&#40;</span>results, count<span style="color: #002200;">&#41;</span>;</pre></div></div>

<p>Taking this simple for() loop and making it execute asynchronously with GCD is actually quite simple.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">dispatch_apply<span style="color: #002200;">&#40;</span>count, dispatch_get_global_queue<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>, <span style="color: #002200;">^</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">size_t</span> i<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    results<span style="color: #002200;">&#91;</span>i<span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> do_work<span style="color: #002200;">&#40;</span>data, i<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
total <span style="color: #002200;">=</span> summarize<span style="color: #002200;">&#40;</span>results, count<span style="color: #002200;">&#41;</span>;</pre></div></div>

<p>I love it.</p>
<h3>GCD Conclusion</h3>
<p>John sums up the importance and far reaching effects of GCD on the future of Mac OS X.</p>
<blockquote><p>When I first heard about Grand Central Dispatch, I was extremely skeptical. The greatest minds in computer science have been working for decades on the problem of how best to extract parallelism from computing workloads. Now here was Apple apparently promising to solve this problem. Ridiculous.</p>
<p>But Grand Central Dispatch doesn&#8217;t actually address this issue at all. It offers no help whatsoever in deciding how to split your work up into independently executable tasks—that is, deciding what pieces can or should be executed asynchronously or in parallel. That&#8217;s still entirely up to the developer (and still a tough problem). What GCD does instead is much more pragmatic. Once a developer has identified something that can be split off into a separate task, GCD makes it as easy and non-invasive as possible to actually do so.</p></blockquote>
<h2>Cocoa Framework Changes of Interest</h2>
<ul>
<li>The faster shutdown time for Snow Leopard is partly possible due to the system <em>killing</em> your application.  You can mark your application as needed to properly shut down and stall the process.  However if you don&#8217;t, your application will be sent the SIGKILL signal.</li>
<li>NSCashe class</li>
<li>NSBlockOperation class</li>
<li>Hefty work to NSURL</li>
<li>Gesture and multitouch event support</li>
<li>Ability to set desktop images</li>
<li>Block-based sheet APIs</li>
<li>Block-based enumerations for lines, words, and the like in NSString and NSAttributedString</li>
<li>New NSPropertyList APIs with better error handling and performance</li>
<li>Core Data integration with Spotlight</li>
<li>Read more at the <a href="http://developer.apple.com/mac/library/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_6.html#//apple_ref/doc/uid/TP40008898-SW5" target="_blank">Mac Dev Center</a> from Apple</li>
</ul>
<h1 style="margin-top:45px">More Reading</h1>
<hr />
<h3>Full Ars Technica Review</h3>
<p>Read the complete <a title="View the &quot;Ars Technica Snow Leopard Review&quot;" href="http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars" target="_blank">Snow Leopard Ars Technica </a> review.</p>
<p>Many thanks to John for the very complete review and insight into Snow Leopard.  All code examples in my article were taken from his.</p>
<h3>Ars Technica Archives</h3>
<ul>
<li><a href="http://arstechnica.com/apple/reviews/2006/03/osx-fiveyears.ars">Five years of Mac OS X</a>, March 24, 2006</li>
</ul>
<ul>
<li> <a href="http://arstechnica.com/apple/reviews/2007/10/mac-os-x-10-5.ars">Mac OS X 10.5 Leopard</a>, October 28, 2007</li>
<li> <a href="http://arstechnica.com/apple/reviews/2005/04/macosx-10-4.ars">Mac OS X 10.4 Tiger</a>, April 28, 2005</li>
<li> <a href="http://arstechnica.com/apple/reviews/2003/11/macosx-10-3.ars">Mac OS X 10.3 Panther</a>, November 9, 2003</li>
<li> <a href="http://arstechnica.com/apple/reviews/2002/09/macosx-10-2.ars">Mac OS X 10.2 Jaguar</a>, September 5, 2002</li>
<li> <a href="http://arstechnica.com/apple/reviews/2001/10/macosx-10-1.ars">Mac OS X 10.1</a> (Puma), October 15, 2001</li>
<li> <a href="http://arstechnica.com/apple/reviews/2001/04/macos-x.ars">Mac OS X 10.0</a> (Cheetah), April 2, 2001</li>
</ul>
<ul>
<li> <a href="http://arstechnica.com/apple/reviews/2000/10/macos-x-beta.ars">Mac OS X Public Beta</a>, October 3, 2000</li>
<li> <a href="http://arstechnica.com/apple/news/2000/06/macos-x-qa-1.ars">Mac OS X Q &amp; A</a>, June 20, 2000</li>
<li> <a href="http://arstechnica.com/apple/reviews/2000/05/mac-os-x-dp4.ars">Mac OS X DP4</a>, May 24, 2000</li>
<li> <a href="http://arstechnica.com/apple/reviews/2000/02/mac-os-x-dp3.ars">Mac OS X DP3: Trial by Water</a>, February 28, 2000</li>
<li> <a href="http://arstechnica.com/apple/reviews/2000/01/macos-x-gui.ars">Mac OS X Update: Quartz &amp; Aqua</a>, January 17, 2000</li>
<li> <a href="http://arstechnica.com/apple/reviews/1999/12/macos-x-dp2.ars">Mac OS X DP2</a>, December 14, 1999</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/09/02/ars-technica-snow-leopard-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cocoa &#8211; Add Application to Dock</title>
		<link>http://www.macfanatic.net/blog/2009/08/31/cocoa-add-application-to-dock/</link>
		<comments>http://www.macfanatic.net/blog/2009/08/31/cocoa-add-application-to-dock/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 18:30:53 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1498</guid>
		<description><![CDATA[Here&#8217;s a little snippet of code for placing anything (or your application) in a user&#8217;s Dock. Wrote it for a project I&#8217;m working on which prompts the user on first launch to place in Dock for them. I know many people disagree with this (as do I), but it&#8217;s what the client is paying for. [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little snippet of code for placing anything (or your application) in a user&#8217;s Dock.  Wrote it for a project I&#8217;m working on which prompts the user on first launch to place in Dock for them.  I know many people disagree with this (as do I), but it&#8217;s what the client is paying for.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="objective-c" style="font-family:monospace;">// Places an icon in the user's dock
- (void) addToDock:(NSString*) path {
&nbsp;
	NSLog(@&quot;Adding %@ to dock&quot;, path);
&nbsp;
	NSAppleScript* placeInDock = [[[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@&quot;do shell script \&quot;defaults write com.apple.dock persistent-apps -array-add 'tile-datafile-data_CFURLString%@_CFURLStringType0'\&quot;&quot;, path]] autorelease];
	[placeInDock executeAndReturnError:nil];
&nbsp;
	NSAppleScript* killDock = [[[NSAppleScript alloc] initWithSource:@&quot;tell application \&quot;Dock\&quot; to quit\nlaunch application \&quot;Dock\&quot;&quot;] autorelease];
	[killDock executeAndReturnError:nil];
&nbsp;
}</pre></td></tr></table></div>

<p class="information">The parameter <em>path</em> needs to be an expanded path.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/08/31/cocoa-add-application-to-dock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xcode 3.2 &#8211; Static Analysis</title>
		<link>http://www.macfanatic.net/blog/2009/08/28/xcode-3-2-static-analysis/</link>
		<comments>http://www.macfanatic.net/blog/2009/08/28/xcode-3-2-static-analysis/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 18:04:40 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1489</guid>
		<description><![CDATA[I have only heard rumblings on the net regarding the new static analyzer built into Xcode 3.2 that ships with Snow Leopard. However, Apple has updated their Dev Center to include documentation on several new developer tools and features with the release of Snow Leopard today. The Xcode analyzer is simply put, a way for [...]]]></description>
			<content:encoded><![CDATA[<p>I have only heard rumblings on the net regarding the new static analyzer built into Xcode 3.2 that ships with Snow Leopard.  However, Apple has updated their Dev Center to include documentation on several new developer tools and features with the release of Snow Leopard today.</p>
<p>The Xcode analyzer is simply put, a way for Xcode to inspect your code <em><strong>logically</strong</em>, in addition to syntactically as traditional compilers do.  The analyzer can investigate each path your code can logically take, reporting errors on memory leaks, type mismatches, return values, and more.</p>
<p>From the Appe Mac Dev Center article:</p>
<blockquote><p>New for Mac OS X v10.6, Xcode 3.2 introduces a revolutionary feature known as static analysis. You can think of static analysis as advanced warnings, identifying bugs in your code before it is run—hence the term “static.” Unlike traditional compiler warnings, the Xcode 3.2 static analyzer has a much deeper understanding of your code. The static analyzer travels down each possible code path, identifying logical errors such as unreleased memory—well beyond simple syntax errors normally found at compile time.</p></blockquote>
<p>Essentially Xcode 3.2 can help you find errors in <strong><em>how you think</em></strong>.  This is a very powerful feature, and should help you write much better code and understand your code better by helping you find logical errors that would normally creep up after your code has went to production (most of the time). </p>
<div class="gallery">
<ul>
<li><a href="http://www.macfanatic.net/blog/wp-content/uploads/2009/08/xcode-clang-1.jpg"><img src="http://www.macfanatic.net/blog/wp-content/uploads/2009/08/xcode-clang-1.jpg" width="72" height="72"></a></li>
<li><a href="http://www.macfanatic.net/blog/wp-content/uploads/2009/08/xcode-clang-2.jpg"><img src="http://www.macfanatic.net/blog/wp-content/uploads/2009/08/xcode-clang-2.jpg" width="72" height="72"></a></li>
<li><a href="http://www.macfanatic.net/blog/wp-content/uploads/2009/08/xcode-clang-3.jpg"><img src="http://www.macfanatic.net/blog/wp-content/uploads/2009/08/xcode-clang-3.jpg" width="72" height="72"></a></li>
</ul>
</div>
<p>For more information the static analyzer used in Xcode 3.2, visit the <a href="http://clang.llvm.org/">clang</a> website, a C frontend for the LLVM compiler.</p>
<p>Read more about Xcode 3.2 and the static analyzer at <a href="http://developer.apple.com/mac/library/featuredarticles/StaticAnalysis/index.html">Apple&#8217;s Mac Dev Center</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/08/28/xcode-3-2-static-analysis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Blocks: Coming to Objective-C Soon</title>
		<link>http://www.macfanatic.net/blog/2008/12/26/blocks-coming-to-objective-c-soon/</link>
		<comments>http://www.macfanatic.net/blog/2008/12/26/blocks-coming-to-objective-c-soon/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 02:55:43 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1321</guid>
		<description><![CDATA[From Mikeash.com: I&#8217;m talking about a new addition to the language being created by Apple which adds anonymous functions to the language. The uses and implications of this weren&#8217;t immediately apparent to me, but my interest was piqued as I continued reading the article.  Mike is quick to point out that anonymous functions would allow [...]]]></description>
			<content:encoded><![CDATA[<p>From Mikeash.com:</p>
<blockquote><p>I&#8217;m talking about a new addition to the language being created by Apple which adds anonymous functions to the language.</p></blockquote>
<p>The uses and implications of this weren&#8217;t immediately apparent to me, but my interest was piqued as I continued reading the article.  Mike is quick to point out that anonymous functions would allow developers to innovate and essentially add features to the language.  Fast iteration was added to ObjC 2.0 in Leopard, allowing us to avoid NSEnumerator and go straight to a for( .. in .. ) statement. </p>
<p>Blocks wouldn&#8217;t exactly have the same syntax, but you could easily implement this in your own code to get the feature.  There are several other examples, some notes that Blocks have access to local variables, and then the following point which is amazing:</p>
<blockquote><p>Another place where blocks will make things much nicer is when dealing with callbacks. If you&#8217;ve ever written much Cocoa code you&#8217;ve probably had to write a sheet callback, and it&#8217;s a pain in the ass. If you need to pass variables through to the other side then it gets really frustrating with code like this:</p></blockquote>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"> <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>method <span style="color: #002200;">&#123;</span>
        <span style="color: #a61390;">int</span> foo;
        <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>bar;
&nbsp;
       <span style="color: #11740a; font-style: italic;">/* do some work with those variables */</span>
        <span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>ctx <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> alloc<span style="color: #002200;">&#93;</span> 
            initWithObjectsAndKeys<span style="color: #002200;">:</span>
                <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span>foo<span style="color: #002200;">&#93;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;foo&quot;</span>,
                bar, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bar&quot;</span>,
                <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
        <span style="color: #002200;">&#91;</span>NSApp beginSheet<span style="color: #002200;">:</span>sheet
            modalForWindow<span style="color: #002200;">:</span>window
            modalDelegate<span style="color: #002200;">:</span>self
            didEndSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>methodSheetDidEnd<span style="color: #002200;">:</span>
             returnCode<span style="color: #002200;">:</span>contextInfo<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span>
            contextInfo<span style="color: #002200;">:</span>ctx<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>methodSheetDidEnd<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSWindow</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>sheet 
            returnCode<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>code 
            contextInfo<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>ctx <span style="color: #002200;">&#123;</span>
        <span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>ctxDict <span style="color: #002200;">=</span> ctx;
        <span style="color: #002200;">&#91;</span>ctxDict autorelease<span style="color: #002200;">&#93;</span>;
&nbsp;
        <span style="color: #a61390;">int</span> foo <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>ctxDict objectforKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;foo&quot;</span><span style="color: #002200;">&#93;</span> intValue<span style="color: #002200;">&#93;</span>;
        <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>bar <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>ctxDict objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bar&quot;</span><span style="color: #002200;">&#93;</span>;
        <span style="color: #11740a; font-style: italic;">/* do some more stuff with those variables
    }</span></pre></td></tr></table></div>

<p> </p>
<blockquote><p>Wow! What a pain that is. Since I removed all the stuff that does work, nearly everything that remains is just boilerplate. Horrible boilerplate whose only purpose is to tell the sheet who to call, and to pack up local information in a way that the sheet can give it back to you later on. Now let&#8217;s imagine we were redoing this API using blocks and see how it would look:</p></blockquote>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>method <span style="color: #002200;">&#123;</span>
        <span style="color: #a61390;">int</span> foo;
        <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>bar;
        <span style="color: #11740a; font-style: italic;">/* do some work with those variables */</span>
        <span style="color: #002200;">&#91;</span>sheet beginSheetModalForWindow<span style="color: #002200;">:</span>window 
            didEndBlock<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> code<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
            <span style="color: #11740a; font-style: italic;">/* do stuff with foo */</span>
            <span style="color: #11740a; font-style: italic;">/* do stuff with bar */</span>
            <span style="color: #11740a; font-style: italic;">/* do stuff with code, or sheet, or window, etc */</span>
        <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>There are several other examples on the page and I think Cocoa developers will be very excited to see this addition to the language, presumably with Snow Leopard in 2009.</p>
<p>Read the article <a href="http://www.mikeash.com/?page=pyblog/friday-qa-2008-12-26.html" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/12/26/blocks-coming-to-objective-c-soon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Genetic Algorithms</title>
		<link>http://www.macfanatic.net/blog/2008/12/02/genetic-algorithms/</link>
		<comments>http://www.macfanatic.net/blog/2008/12/02/genetic-algorithms/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 17:05:55 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1310</guid>
		<description><![CDATA[For the final installment in the Biologically Inspired Computation series, we&#8217;ll be taking a look at genetic algorithms. Theory From Wikipedia: A genetic algorithm (GA) is a search technique used in computing to find exact or approximate solutions to optimization and search problems. Genetic algorithms are categorized as global search heuristics. Genetic algorithms are a particular class of evolutionary algorithms (also known as evolutionary computation) that use techniques inspired by evolutionary biology such as inheritance, mutation, selection, and crossover (also [...]]]></description>
			<content:encoded><![CDATA[<p>For the final installment in the <a href="http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/">Biologically Inspired Computation series</a>, we&#8217;ll be taking a look at genetic algorithms.</p>
<h3>Theory</h3>
<p>From Wikipedia:</p>
<blockquote><p>A <strong>genetic algorithm (GA)</strong> is a <a class="mw-redirect" title="Search" href="http://en.wikipedia.org/wiki/Search">search</a> <a class="extiw" title="wikt:technique" href="http://en.wiktionary.org/wiki/technique">technique</a> used in <a title="Computing" href="http://en.wikipedia.org/wiki/Computing">computing</a> to find exact or <a class="mw-redirect" title="Approximate" href="http://en.wikipedia.org/wiki/Approximate">approximate</a> solutions to <a title="Optimization (mathematics)" href="http://en.wikipedia.org/wiki/Optimization_(mathematics)">optimization</a> and <a class="mw-redirect" title="Search" href="http://en.wikipedia.org/wiki/Search">search</a> <a title="Problem" href="http://en.wikipedia.org/wiki/Problem">problems</a>. Genetic algorithms are <a class="mw-redirect" title="Categorize" href="http://en.wikipedia.org/wiki/Categorize">categorized</a> as <a title="Global optimization" href="http://en.wikipedia.org/wiki/Global_optimization">global search heuristics</a>. Genetic algorithms are a particular class of <a title="Evolutionary algorithm" href="http://en.wikipedia.org/wiki/Evolutionary_algorithm">evolutionary algorithms</a> (also known as <a title="Evolutionary computation" href="http://en.wikipedia.org/wiki/Evolutionary_computation">evolutionary computation</a>) that use techniques inspired by <a title="Evolutionary biology" href="http://en.wikipedia.org/wiki/Evolutionary_biology">evolutionary biology</a> such as <a class="mw-redirect" title="Biological inheritance" href="http://en.wikipedia.org/wiki/Biological_inheritance">inheritance</a>, <a title="Mutation (genetic algorithm)" href="http://en.wikipedia.org/wiki/Mutation_(genetic_algorithm)">mutation</a>, <a title="Selection (genetic algorithm)" href="http://en.wikipedia.org/wiki/Selection_(genetic_algorithm)">selection</a>, and <a title="Crossover (genetic algorithm)" href="http://en.wikipedia.org/wiki/Crossover_(genetic_algorithm)">crossover</a> (also called <a title="Recombination" href="http://en.wikipedia.org/wiki/Recombination">recombination</a>).</p></blockquote>
<p>I even took the liberty of including my paper on my findings with this project, just because there are so many parameters to test and creating the graphs can be rather time consuming.  So take a look at the paper if you would like to read up on the relationships between the number of chromosomes and the average fitness of the population at any given generation, for example.</p>
<p>More uses of NSOperation and NSOperationQueue for multithreading in this project.</p>
<h3>Download</h3>
<p><a href="http://www.macfanatic.net/downloads/bio_series/genetic-algorithms-source.dmg">Xcode Project (3.1 or later)</a> | Leopard Only</p>
<p><a href="http://www.macfanatic.net/downloads/bio_series/genetic-algorithms.dmg">Genetic Algorithm</a> | Leopard Only</p>
<p><a href="http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/">Biologically Inspired Computation Series</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/12/02/genetic-algorithms/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Back Propagation Neural Network</title>
		<link>http://www.macfanatic.net/blog/2008/12/01/back-propagation-neural-network/</link>
		<comments>http://www.macfanatic.net/blog/2008/12/01/back-propagation-neural-network/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 16:50:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1309</guid>
		<description><![CDATA[For the third installment in the Biologically Inspired Computation series, we take a look at a more complex version of neural networking (as compared to our last installment where we investigated a Hopfield Network). Theory Essentially, we are running a network that we can train to recognize data, or solve a problem. We do this [...]]]></description>
			<content:encoded><![CDATA[<p>For the third installment in the <a href="http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/">Biologically Inspired Computation series</a>, we take a look at a more complex version of neural networking (as compared to our last installment where we investigated a <a href="http://www.macfanatic.net/blog/2008/11/27/hopfield-network-simulator/">Hopfield Network</a>).</p>
<h3>Theory</h3>
<p>Essentially, we are running a network that we can train to recognize data, or solve a problem. We do this by giving the network sample data, and for each set of sample data, running the network through one time. We calculate the error of this run, adjust the weight of the connections between all the neurons in the entire network, and repeat. After running through all the sample data we have adjusted the weights to &#8216;recognize&#8217; the data. Then, given another set of data, the network is trained to perform the same operation, such as classification (maybe determining forged vs authentic bank notes) or just solving a mathematical equation, such as we do in this particular example.</p>
<h3>Code</h3>
<p>This simulator is written in Cocoa, requires Xcode 3.1 or later, and is Leopard only. Subclasses NSOperation for multithreading, and have two subclassed NSViews for a &#8216;Safari Downloads&#8217; style window, just showing the progress of each running experiment, with a cancel button beside it.</p>
<h3>Download</h3>
<p><a href="http://www.macfanatic.net/downloads/bio_series/neural-net-source.dmg">Xcode Project (3.1 or later)</a> | Leopard Only</p>
<p><a href="http://www.macfanatic.net/downloads/bio_series/neural-net.dmg">Neural Net</a> | Leopard Only</p>
<p><a href="http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/">Biologically Inspired Computation Series</a></p>
<p><a href="http://en.wikipedia.org/wiki/Backpropagation" target="_blank">Back Propagation on Wikipedia</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/12/01/back-propagation-neural-network/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Biologically Inspired Computation Series</title>
		<link>http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/</link>
		<comments>http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 17:50:14 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1308</guid>
		<description><![CDATA[This is a series of 4 simulators, all written in Cocoa, experimenting with topics such as artificial intelligence with neural networks, cellular automaton, and genetic algorithms.  The full source, along with project description and detailed implementation guidelines are included with each project.   Activation/Inhibition Cellular Automaton This is a simulator written in Cocoa for running [...]]]></description>
			<content:encoded><![CDATA[<p>This is a series of 4 simulators, all written in Cocoa, experimenting with topics such as artificial intelligence with neural networks, cellular automaton, and genetic algorithms.  The full source, along with project description and detailed implementation guidelines are included with each project.</p>
<p> </p>
<p><a href="http://www.macfanatic.net/blog/2008/10/03/activationinhibtion-cellular-automaton-simulator-posted/">Activation/Inhibition Cellular Automaton</a></p>
<p>This is a simulator written in Cocoa for running a series of experiments and creating Excel files with the results.  Activation/Inhibition CAs are similar to how a cell on a zebra determines if it should be white or black.  There is no overall governing authority, yet patterns arise naturally.  Intermediate example of using Cocoa classes such as open/save panels, notifications and the file manager.  Excellent for examining how to code complex mathematical formulas and summations in C code.</p>
<p> </p>
<p><a href="http://www.macfanatic.net/blog/2008/11/27/hopfield-network-simulator/">Hopfield Network</a></p>
<p>This is a simulator written in Cocoa to test the relationship between the number of stored patterns in a Hopfield Network and the accuracy with which they are remembered.  A very interesting exercise making use of NSOperation and NSOperationQueue for simple multithreading and general Cocoa design patterns such as using a delegate.</p>
<p> </p>
<p><a href="http://www.macfanatic.net/blog/2008/12/01/back-propagation-neural-network/">Back Propagation Neural Network</a></p>
<p>Another Cocoa simulator written to investigate the relationship between parameters for a network.  Given a set of data, can train the network to recognize that data.  Then from there, the network can &#8216;solve&#8217; a problem.  In this simulation, there are two mathematical equations that are solved with this network.  Illustrates custom views, multithreading, and more.</p>
<p> </p>
<p><a href="http://www.macfanatic.net/blog/2008/12/02/genetic-algorithms">Genetic Algorithms</a></p>
<p>The last Cocoa simulator in the series, written to investigate the relationship between input parameters for a given population of organisms over several generations.  Parameters include the probability of mutation in the offspring&#8217;s chromosomes, number of chromosomes per individual, how much sharing of chromosomes occurs when two individuals mate, and creating your own fitness function to quantify the &#8216;best fit&#8217; individual based upon the DNA.  Multithreading and general Cocoa design patterns.</p>
<p> </p>
<h3>Going Further</h3>
<p>I find this general area of computer science very interesting and would love to spend time researching and learning more about neural networks and genetic algorithms.  If you have any suggestions or comments about the code or projects in general, I&#8217;d love to hear from you, so <a href="mailto:matt@macfanatic.net">drop me an email</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hopfield Network Simulator</title>
		<link>http://www.macfanatic.net/blog/2008/11/27/hopfield-network-simulator/</link>
		<comments>http://www.macfanatic.net/blog/2008/11/27/hopfield-network-simulator/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 16:53:21 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1307</guid>
		<description><![CDATA[For the second installment of the Biologically Inspired Computation series, we&#8217;ll be taking a look at a simple neural network called a Hopfield Network. Theory From Wikipedia:   A Hopfield net is a form of recurrent artificial neural network invented by John Hopfield. Hopfield nets serve as content-addressable memory systems with binary threshold units. They [...]]]></description>
			<content:encoded><![CDATA[<p>For the second installment of the <a href="http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/">Biologically Inspired Computation series</a>, we&#8217;ll be taking a look at a simple neural network called a Hopfield Network.</p>
<h3>Theory</h3>
<p>From Wikipedia:</p>
<blockquote><p>  A Hopfield net is a form of recurrent artificial neural network invented by John Hopfield. Hopfield nets serve as content-addressable memory systems with binary threshold units. They are guaranteed to converge to a local minimum, but convergence to one of the stored patterns is not guaranteed.</p></blockquote>
<p>Basically, you can fine tune the weights (connections between neurons) in the network so as to &#8216;store&#8217; data in the network. Imagine a square area, not necessarily flat, with a few deep potholes in it. Now, we start the network anywhere on this grid, and as the network progresses, it moves towards the nearest pothole. At the bottom of this pothole is a stored pattern, which is &#8216;remembered&#8217; by the network. So given a corrupt image, the network can &#8216;remember&#8217; the real image as it works its way to the sinkhole.</p>
<p>This simulation investigates how many patterns a network can hold versus the accuracy with which the network can recall. For example, a network with only 5 neurons simply cannot accurately recall many patterns, and this simulator allows you to investigate this relationship.</p>
<p>There are two PDFs included with the Xcode project, a theoretical overview and a detailed implementation guide. The simulator produces comma separated value (CSV) files, which can be opened in Numbers or Excel for graphing.</p>
<h3>Get Started Now</h3>
<p>Of interest to Cocoa programmers, this project makes use of NSOperation and NSOperation queue for quick and efficient multithreading.</p>
<p><a href="http://www.macfanatic.net/downloads/bio_series/hopfield_network_source.dmg">Xcode Project (3.1 or later)</a> | Leopard Only</p>
<p><a title="Hopfield Network Application" href="http://www.macfanatic.net/downloads/bio_series/hopfield_network_universal.dmg">Hopfield Network</a> | Leopard Only</p>
<p><a href="http://en.wikipedia.org/wiki/Hopfield_network" target="_blank">Hopfield Network on Wikipedia</a></p>
<p><a href="http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/">Biologically Inspired Computation Series</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/11/27/hopfield-network-simulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started Programming for the Mac</title>
		<link>http://www.macfanatic.net/blog/2008/10/06/getting-started-programming-for-the-mac/</link>
		<comments>http://www.macfanatic.net/blog/2008/10/06/getting-started-programming-for-the-mac/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 19:17:22 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/10/06/getting-started-programming-for-the-mac/</guid>
		<description><![CDATA[Recently, I have had several people come to me asking for advice about Mac programming. A few of these have experience in web standards and Flash/Flex/Air development, while others were in the Java/C++ crowd, and the last guy was just getting started with no experience at all. The fact that I have had so many [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I have had several people come to me asking for advice about Mac programming. A few of these have experience in web standards and Flash/Flex/Air development, while others were in the Java/C++ crowd, and the last guy was just getting started with no experience at all.</p>
<p>The fact that I have had so many approach me, with almost the identical question raises a very valid point. Just where does one find the best documentation and sample code to get started in Cocoa development? With so many developers making the switch to iPhone and then the Mac (and hopefully <a href="http://www.macfanatic.net/blog/2008/06/14/cappuccino-objective-j-and-280slidescom/" target="_top">Cappuccino</a> for web), I think this post will only gain value as time goes on.</p>
<p>So I have compiled a list of extremely useful resources. If you spent enough time googling, you would certainly run across these sites yourself. However, I&#8217;m saving you something very precious: time. These vary in range of beginner programmer to advanced genius, so there is a little something for everyone. Keep in mind that as of writing this, official publications on Objective-C 2.0 are just barely in print, and anything for iPhone is still in the works, as the NDA keeping publishers from releasing books <a href="http://www.macfanatic.net/blog/2008/10/01/iphone-nda-dead/" target="_top">was just lifted a week ago</a>.</p>
<ul>
<li>THE doc on the Cocoa language, from Apple, <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/chapter_1_section_1.html">HTML</a> or <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/ObjC.pdf">PDF</a></li>
<li><a href="http://developer.apple.com/">http://developer.apple.com</a> &#8211; Great place to start for tutorials, etc in general</li>
<li><a href="http://cocoablogs.com/">http://cocoablogs.com/</a> &#8211; List of all the top Cocoa developers blogs</li>
<li><a href="http://www.cocoadev.com/index.pl">http://www.cocoadev.com/index.pl</a> &#8211; THE Cocoa message boards</li>
<li><a href="http://forums.cocoaforge.com/index.php">http://forums.cocoaforge.com/index.php</a> &#8211; Another great Cocoa forum, more advanced</li>
<li><a href="http://inexdo.com/CocoaNav">http://inexdo.com/CocoaNav</a> &#8211; Wonderful little piece of software for viewing Cocoa headers (information on classes and heirachy)</li>
</ul>
<p>
The finale comes with &#8220;<a href="http://www.amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619" target="_blank">Cocoa Programming Mac OS X 3rd Edition</a>&#8220;. It assumes very little programming knowledge and yet contains a good 80% of what you need to know when designing a full Cocoa programming. Key design concepts are explained in great detail and it is a wonderful resource.</p>
<p>If you have anything to add to this list, please leave a comment on this post or <a href="mailto:matt@macfanatic.net" target="_blank">send me an email</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/10/06/getting-started-programming-for-the-mac/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Activation/Inhibtion Cellular Automaton Simulator Posted</title>
		<link>http://www.macfanatic.net/blog/2008/10/03/activationinhibtion-cellular-automaton-simulator-posted/</link>
		<comments>http://www.macfanatic.net/blog/2008/10/03/activationinhibtion-cellular-automaton-simulator-posted/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 02:46:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/10/03/activationinhibtion-cellular-automaton-simulator-posted/</guid>
		<description><![CDATA[This is the first installment in the Biologically Inspired Computation series, examining pattern formation with cellular automaton. Theory Imagine a single skin cell on a zebra. How does the cell know whether it should be white or black? Simply puts, the cell takes into account the value of the surrounding cells. If it&#8217;s surrounded by [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first installment in the <a href="http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/">Biologically Inspired Computation series</a>, examining pattern formation with cellular automaton.</p>
<p><strong>Theory</strong></p>
<p>Imagine a single skin cell on a zebra. How does the cell know whether it should be white or black? Simply puts, the cell takes into account the value of the surrounding cells. If it&#8217;s surrounded by several black cells, then more than likely it should be black, right? Over time the cell keep looking at the cells around it, and the system changes. Eventually, the system will reach a pattern where it doesn&#8217;t change anymore. When this happens, the system has converged. Overall this is the basic theory behind pattern formation, on which the Activation/Inhibition Cellular Automaton is based.</p>
<p>This project is designed to investigate how varying parameters in the mathematical equation affects the pattern formation. For example, there is a parameter that influences how many cells away actually influence the current cell&#8217;s decision to be white or black. A larger number means that cells farther away are considered, while a smaller number means the converse. By varying a total of six parameters in the experiment, one can see the effect that these parameters have on the system.</p>
<p><img style="margin-left:20px;" src="http://www.macfanatic.net/blog/wp-content/uploads/2008/10/step-14.jpg" alt="step-14.jpg" width="100" height="100" /> <img style="margin-left:75px;" src="http://www.macfanatic.net/blog/wp-content/uploads/2008/10/step-9-1.jpg" alt="step-9-1.jpg" width="100" height="100" /> <img style="margin-left:75px;" src="http://www.macfanatic.net/blog/wp-content/uploads/2008/10/step-6.jpg" alt="step-6.jpg" width="100" height="100" /> <img style="margin-left:75px;" src="http://www.macfanatic.net/blog/wp-content/uploads/2008/10/step-9.jpg" alt="step-9.jpg" width="100" height="100" /></p>
<h3>Purpose</h3>
<p>The Xcode project, aica, is written to perform a few different tasks. First off, you can quickly run a set of sample experiments that will produce some interesting converged systems. By interesting, I mean that the images representing the patterns are visually intriguing, as well as mathematically. AICA also allows a user to quickly run one experiment with a set of parameters, or run a larger set of experiments with different parameters from file.</p>
<p>In designing this application for my Biologically Inspired Computation course, I needed quantitative measurements describing what is happening in the system. These measurements are calculated once the system has converged and are not very pretty equations, involving lots of summations, logarithms and probability. I&#8217;m not going to delve into the mechanics and descriptions of these calculations, even though that was part of my report.</p>
<h3>Design</h3>
<p>I needed this to perform the basic tasks outlined above. In addition, I also wanted to have better statistics, so for each set of parameters ran (an experiment), I might want to run this several times and take the average of the calculated values describing the system. I classified each of these as a &#8220;trial&#8221;. So, the application structure is beginning to look something like this:</p>
<ul>
<li>Controller code for interacting with the interface and managing the experiments to be ran</li>
<li>An experiment, which will run several trials and average the results, creating an Excel file with data</li>
<li>A trial, which runs until convergence, writing image files for each step in the simulation</li>
</ul>
<p>Feel free to look through project. There are two PDF files accompanying, containing the original project description and theory behind the simulation as well as a more technical document providing hints for writing the summations and mathematical equations as C code. This also contains some specific Cocoa programming techniques of interest to newbies, including using a NSProgressIndicator, Objective-C properties, NSNotifications, sheet programming, using NSSavePanel and NSOpenPanel, as well as creating directories and files using NSFileManager.</p>
<h3>Get Started Now</h3>
<p>Overall, if you have any comments or questions about the project, I&#8217;d love to hear from you. Even if you aren&#8217;t specifically interested, you should download the Application itself and give it a quick test run. Universal build, Leopard only. I also included some more sample files for systematically varying the parameters as I used in my project and used to draw conclusions about the behavior.</p>
<p><a href="http://www.macfanatic.net/downloads/bio_series/aica.zip">AICA Simulator (Leopard Only)</a></p>
<p><a href="http://www.macfanatic.net/downloads/bio_series/aica_source.zip">Source Code and Project Files</a></p>
<p><a href="http://www.macfanatic.net/blog/2008/11/28/biologically-inspired-computation-series/">Biologically Inspired Computation Series</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/10/03/activationinhibtion-cellular-automaton-simulator-posted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding Tip: Comma Trick</title>
		<link>http://www.macfanatic.net/blog/2008/09/21/coding-tip-comma-trick/</link>
		<comments>http://www.macfanatic.net/blog/2008/09/21/coding-tip-comma-trick/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 21:14:14 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/09/21/coding-tip-comma-trick/</guid>
		<description><![CDATA[Through the years I&#8217;ve been fervently coding, I would have thought this would have came up during my travels. Just how amazing the comma can be. 1 2 3 for &#40; int i = 0, NSPoint p = &#91;self updatingCell&#93;; i &#60; maxIterations &#38;&#38; p.x &#62; 0; i++, p = &#91;self updatingCell&#93; &#41; &#123; // [...]]]></description>
			<content:encoded><![CDATA[<p>Through the years I&#8217;ve been fervently coding, I would have thought this would have came up during my travels. Just how amazing the comma can be.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> <span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>, <span style="color: #a61390;">NSPoint</span> p <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self updatingCell<span style="color: #002200;">&#93;</span>; i &lt; maxIterations <span style="color: #002200;">&amp;&amp;</span> p.x &gt; <span style="color: #2400d9;">0</span>; i<span style="color: #002200;">++</span>, p <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self updatingCell<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
<span style="color: #11740a; font-style: italic;">// Do something interesting with this NSPoint</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>I&#8217;ve used the above approach several times, letting me compact code when in loops. However, the next trick presented by <a href="http://www.inexdo.com" target="_blank">Parmanoir</a>, developer of <a href="http://www.inexdo.com/CocoaNav" target="_blank">CocoaNav</a>, is one I never thought of and the article gives a wonderful explanation of the comma operator in C and family.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Log and return</span>
<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>error<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span> NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;MyFunction failed with error: %@&quot;</span>, error<span style="color: #002200;">&#41;</span>, <span style="color: #a61390;">NO</span>;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/09/21/coding-tip-comma-trick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sparkle 1.5 Beta Available</title>
		<link>http://www.macfanatic.net/blog/2008/06/19/sparkle-15-beta-available/</link>
		<comments>http://www.macfanatic.net/blog/2008/06/19/sparkle-15-beta-available/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 14:48:56 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/06/19/sparkle-15-beta-available/</guid>
		<description><![CDATA[A little overshadowed in the developer community by WWDC and all the inevitable ramblings that take place after, the famous Sparkle framework for automatically updating applications has seen an impressive update. Still in beta, v1.5 introduces several new features including: Support for .pkg files Support for receiving demographic information from users Can update bundles, not [...]]]></description>
			<content:encoded><![CDATA[<p>A little overshadowed in the developer community by WWDC and all the inevitable ramblings that take place after, the famous Sparkle framework for automatically updating applications has seen an impressive update.</p>
<p><img src="http://www.macfanatic.net/blog/wp-content/uploads/2008/06/picture-1.png" alt="" title="Sparkle Teaser" class="alignnone size-full wp-image-1254" style="width:675px" /></p>
<p>Still in beta, v1.5 introduces several new features including:</p>
<ul>
<li>Support for .pkg files</li>
<li>Support for receiving demographic information from users</li>
<li>Can update bundles, not restricted to just .app applications</li>
<li>Minimum system version checking for users</li>
<li>Garbage Collection</li>
<li>Better version comparison algorithm</li>
<li>DSA instead of less secure MD5</li>
<li>Won&#8217;t update if app is running from a disk image</li>
</ul>
<p>Andy has also taken the time to dramatically simplify the Sparkle site itself, and move the project over to Launchpad for easier development. Be sure to check out this new version to incorporate into your apps to gain the new features.</p>
<p><a href="http://sparkle.andymatuschak.org/" target="_blank">Sparkle Page</a></p>
<p><a href="https://launchpad.net/sparkle" target="_blank">Sparkle on LaunchPad</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/06/19/sparkle-15-beta-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BGHUD AppKit &#8211; Impressive HUD Framework</title>
		<link>http://www.macfanatic.net/blog/2008/06/17/bghud-appkit-impressive-hud-framework/</link>
		<comments>http://www.macfanatic.net/blog/2008/06/17/bghud-appkit-impressive-hud-framework/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 18:13:56 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/06/19/bghud-appkit-impressive-hud-framework/</guid>
		<description><![CDATA[The lack of HUD controls from Apple in Leopard is a hot topic. The HUD style has picked up quite a following over the last few years, and without an official release of the controls from Apple, developers have been left to their own devices to replicate that style. The community has been hard at [...]]]></description>
			<content:encoded><![CDATA[<p>The lack of HUD controls from Apple in Leopard is a hot topic. The HUD style has picked up quite a following over the last few years, and without an official release of the controls from Apple, developers have been left to their own devices to replicate that style.</p>
<p>The community has been hard at work and before now the most notable project being developed was by the Shiira web browser team, called BlkAppKit.</p>
<p>Tim Davis from Binary Method has been hard at work creating an awesome framework of HUD controls. Unlike the few other kits already out there, BGHUD AppKit does not use images to create the controls. None at all. These controls are beautiful and ready for Resolution Independence. Also worth noting is the shear number of controls already available, the speed with which the developer is creating new ones and the community that is using it, including RealMac Software, developers of RapidWeaver.<a href="http://www.binarymethod.com/content/bghudappkit.php" target="_blank"><img src="http://www.macfanatic.net/blog/wp-content/uploads/2008/06/hud.png" width="700" height="500" alt="hud.png"  style="width:675px"/></a></p>
<p>Another unique feature to the BGHUD AppKit is theming. Tim has taken an interesting approach to theming the controls to better match your application, if you need something different than the default HUD style. Place your controls on the windows and set the custom class, as you would with any other custom control in Interface Builder. Building and Running the application at this time will show no difference. However, if you initiate an object controller, of either &#8220;BGThemeManager&#8221; or &#8220;BGGradientTheme&#8221; and connect the outlet of every control to this object, your controls are now updated. Using the &#8220;BGGradientTheme&#8221; gives you the default appearance, while using the theme manager lets you customize the controls.</p>
<p>This seems a little tedious upfront, especially if you want to just use the default appearance. However, if you needed to change the overall appearance of your application, instead of subclassing all of these controls, you can simply subclass and use the update theme manager. Therefore, it does pay off in that respect.</p>
<p>My personal recommendation: If I don&#8217;t set the outlet on my control to a theme manager, then use the default HUD behavior. That way I don&#8217;t even have to worry with it. But, the work put into this framework is phenomenal and it seems that Tim isn&#8217;t sleeping until he implements every last single available control perfectly. If you need HUD controls in your project, I strongly believe this is the best framework available. The work is beautiful, it&#8217;s under heavy and active development, the developer is responsive to requests, it&#8217;s easily theme-able, and all the controls are already Resolution Independent.</p>
<p class="information">Update: Tim has already read the post and really liked my recommendation for simplifying the ThemeManager behavior. Even better, he&#8217;s already implemented the change into the framework, so checking out subsequent version from SVN are now more friendly. Check out his blog for more details and to get your copy.</p>
<p><a href="http://www.binarymethod.com/content/bghudappkit.php" target="_blank">BGHUD AppKit Home</a></p>
<p><a href="http://shiira.jp/hmblkappkit/en.html" target="_blank">Shiira BlkAppKit</a></p>
<p><a href="http://www.realmacsoftware.com/" target="_blank">RealMac Software</a></p>
<p><a href="http://www.macfanatic.net/blog/2007/11/29/hud-controls-in-leopard/">My previous post on HUD controls in Leopard</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/06/17/bghud-appkit-impressive-hud-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Versions Beta Released &#8211; Finally</title>
		<link>http://www.macfanatic.net/blog/2008/06/07/versions-beta-released-finally/</link>
		<comments>http://www.macfanatic.net/blog/2008/06/07/versions-beta-released-finally/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 01:49:56 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/06/07/versions-beta-released-finally/</guid>
		<description><![CDATA[For any of those out there wondering if Versions was vaporware like that YouTube client promised forever back, there is a little hope. From the Versions website: Whether you&#8217;re a designer, developer, editor or project manager, chances are you already have plenty on your mind. Versions saves you the hassle and makes working with Subversion [...]]]></description>
			<content:encoded><![CDATA[<p>For any of those out there wondering if Versions was vaporware like that YouTube client promised forever back, there is a little hope.</p>
<p>From the <a href="http://versionsapp.com/" target="_blank">Versions website</a>:</p>
<blockquote>
<p>Whether you&#8217;re a designer, developer, editor or project manager, chances are you already have plenty on your mind. Versions saves you the hassle and makes working with Subversion easy for your entire team. Thanks to Versions&#8217; clear-cut approach to Subversion, novices and power users alike will enjoy using it. And if you haven&#8217;t moved to Subversion yet, now is the time.</p>
</blockquote>
<p>
<a href="http://versionsapp.com/" target="_blank"><img src="http://www.macfanatic.net/blog/wp-content/uploads/2008/06/ui-browse.jpg" width="700" height="476" alt="ui_browse.jpg" style="width:675px" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/06/07/versions-beta-released-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick iPhone SDK Observation</title>
		<link>http://www.macfanatic.net/blog/2008/03/07/quick-iphone-sdk-observation/</link>
		<comments>http://www.macfanatic.net/blog/2008/03/07/quick-iphone-sdk-observation/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 18:42:12 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/03/07/quick-iphone-sdk-observation/</guid>
		<description><![CDATA[I spent most of last evening and some of this morning sifting through the various documentation and classes for the UIKit framework distributed with the iPhone/Cocoa Touch SDK. So, for the very quick, but cool observation. You can easily create a UITextField to handle text input. The interesting part comes into play because there is [...]]]></description>
			<content:encoded><![CDATA[<p>I spent most of last evening and some of this morning sifting through the various documentation and classes for the UIKit framework distributed with the iPhone/Cocoa Touch SDK. So, for the very quick, but cool observation.</p>
<p>You can easily create a UITextField to handle text input. The interesting part comes into play because there is a keyboard associated with the UITextField, obviously for providing input. That keyboard can be specified what action to do when the return button is pressed, giving a way to process the text. The cool part is, it&#8217;s extremely easy for developers to use the many different types of keyboards present on the iPhone. For example, there is a numeric keyboard, the default keyboard, one for entering URLs, one for entering email addresses, and so on. Below is a quick code block, adapted from the &#8220;Hello World&#8221; example.</p>
<p class="code">aTextField.borderStyle = UITextFieldBorderStyleRounded;<br />
aTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;<br />
aTextField.placeholder = @&#8221;Your name&#8221;;<br />
aTextField.keyboardType = UIKeyboardTypeEmailAddress;</p>
<p>Some other examples of keyboard types:</p>
<ul>
<li>UIKeyboardTypeDefault</li>
<li>UIKeyboardTypeNamePhonePad</li>
<li>UIKeyboardTypeNumberPad</li>
<li>UIKeyboardTypeNumbersAndPunctuation</li>
<li>UIKeyboardTypePhonePad</li>
<li>UIKeyboardTypeURL</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/03/07/quick-iphone-sdk-observation/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Cocoa Is My Girlfriend</title>
		<link>http://www.macfanatic.net/blog/2008/03/04/cocoa-is-my-girlfriend/</link>
		<comments>http://www.macfanatic.net/blog/2008/03/04/cocoa-is-my-girlfriend/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 05:08:41 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/03/04/cocoa-is-my-girlfriend/</guid>
		<description><![CDATA[For those who haven&#8217;t heard of the newest Cocoa development blog, you should check out Cocoa is My Girlfriend. I first came across the site a few weeks ago with its first article, but now that the author has published some good articles, it&#8217;s definitely worth mentioning. There is an excellent NSOperation and NSOperationQueue example, [...]]]></description>
			<content:encoded><![CDATA[<p>For those who haven&#8217;t heard of the newest Cocoa development blog, you should check out Cocoa is My Girlfriend. I first came across the site a few weeks ago with its first article, but now that the author has published some good articles, it&#8217;s definitely worth mentioning. There is an excellent NSOperation and NSOperationQueue example, as well as a couple using Core Animation.</p>
<p><a href="http://www.cimgf.com/" target="_blank">Cocoa is My Girlfriend</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/03/04/cocoa-is-my-girlfriend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cocoa Programming for Mac OS X 3rd Edition</title>
		<link>http://www.macfanatic.net/blog/2008/01/21/cocoa-programming-for-mac-os-x-3rd-edition/</link>
		<comments>http://www.macfanatic.net/blog/2008/01/21/cocoa-programming-for-mac-os-x-3rd-edition/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 03:20:10 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/01/21/cocoa-programming-for-mac-os-x-3rd-edition/</guid>
		<description><![CDATA[For everyone who has been anxiously awaiting the revised 3rd edition of the wonderful book on Cocoa Programming, the wait is over! The 3rd edition is the first release of the book since Panther and will cover all technologies released in Tiger as well as Leopard. Very exciting news indeed, pre-order your copy at Amazon [...]]]></description>
			<content:encoded><![CDATA[<p>For everyone who has been anxiously awaiting the revised 3rd edition of the wonderful book on Cocoa Programming, the wait is over! The 3rd edition is the first release of the book since Panther and will cover all technologies released in Tiger as well as Leopard. Very exciting news indeed, pre-order your copy at <a href="http://www.amazon.com/Cocoa-Programming-Mac-OS-3rd/dp/0321503619" target="_blank">Amazon here</a>.</p>
<p>On the Big Nerd Ranch website, the release is marked simply as &#8220;Spring 2008&#8243;. However, the publishing date on Amazon is marked as June 2, 2008. Pre-ordering through Amazon will guarantee you receive your copy as soon as it&#8217;s available.</p>
<p>Found via | <a href="http://ranchero.com/" target="_blank">Ranchero.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/01/21/cocoa-programming-for-mac-os-x-3rd-edition/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Objective-C 2.0 and Leopard Classes</title>
		<link>http://www.macfanatic.net/blog/2007/12/29/objective-c-20-and-leopard-classes/</link>
		<comments>http://www.macfanatic.net/blog/2007/12/29/objective-c-20-and-leopard-classes/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 07:36:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/12/29/objective-c-20-and-leopard-classes/</guid>
		<description><![CDATA[So I have finally had time to code to my heart&#8217;s content over the holiday break. I thought that I would share some of my thoughts and experiences with programming for Leopard. Fast Enumeration Cocoa now implements a foreach() type of loop, which cleans up code tremendously. Iterating over an array or dictionary is pretty [...]]]></description>
			<content:encoded><![CDATA[<p>So I have finally had time to code to my heart&#8217;s content over the holiday break. I thought that I would share some of my thoughts and experiences with programming for Leopard.</p>
<h3>Fast Enumeration</h3>
<p>Cocoa now implements a foreach() type of loop, which cleans up code tremendously. Iterating over an array or dictionary is pretty common stuff and being able to condense code from:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSEnumerator</span> <span style="color: #002200;">*</span>e <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>myArray objectEnumerator<span style="color: #002200;">&#93;</span>;
<span style="color: #a61390;">id</span> item;
<span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span> item <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>e nextObject<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@&quot;</span>, <span style="color: #002200;">&#91;</span>item printSomething<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>to a more elegant:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">id</span> item;
<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> item <span style="color: #a61390;">in</span> myArray <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
NSlog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@&quot;</span>, <span style="color: #002200;">&#91;</span>item printSomething<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<h3>Properties</h3>
<p>Properties are a wonderful addition to Cocoa and essentially eliminate writing basic accessor methods for your objects (setters and getters).</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> Song <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span> <span style="color: #002200;">&#123;</span> 
<span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> title; 
Artist<span style="color: #002200;">*</span> artist; 
<span style="color: #400080;">NSDate</span><span style="color: #002200;">*</span> dateAdded; 
<span style="color: #002200;">&#125;</span> 
<span style="color: #a61390;">@property</span><span style="color: #002200;">&#40;</span>readwrite, copy<span style="color: #002200;">&#41;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> title; 
<span style="color: #a61390;">@property</span><span style="color: #002200;">&#40;</span>readwrite, copy<span style="color: #002200;">&#41;</span>Artist<span style="color: #002200;">*</span> artist; 
<span style="color: #a61390;">@property</span><span style="color: #002200;">&#40;</span>readwrite, copy<span style="color: #002200;">&#41;</span><span style="color: #400080;">NSDate</span><span style="color: #002200;">*</span> dateAdded; 
<span style="color: #a61390;">@implementation</span> Song <span style="color: #a61390;">@synthesize</span> title, artist, dateAdded;</pre></div></div>

<p>The ObjC 2.0 compiler gives you extreme flexibility with properties, beyond just the basic use of accessors here. You can specify a property to be readonly instead of readwrite, or to retain or assign instead of copy.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">@dynamic title; <span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>title <span style="color: #002200;">&#123;</span> <span style="color: #002200;">&#125;</span></pre></div></div>

<p>The above would require you to implement the method yourself, letting the compiler know you are handling that.</p>
<h3>NSTreeNode</h3>
<p>Not a feature of the ObjC language, but certainly a nice addition to help using NSTreeController. NSTreeNode is a wrapper object which aids in creating trees. Just create a NSTreeNode and add other NSTreeNode objects to the -mutableChildNodes array and you are on your way to a tree. Binding this tree to a NSTreeController is relatively simple as well. Of note, remember that if you are using NSOutlineView delegate methods, you receive a NSTreeNode object now, so you must use -representedObject on &#8220;id item&#8221;.</p>
<p>A further note, when using the &#8220;selection&#8221; controller key on a NSTreeController, the controller returns an array of NSTreeControllerProxyObjects. Either call -self on the NSTreeControllerProxyObject or when using bindings (binding a second NSTreeController to the &#8220;selection&#8221; of the first one) remember to use &#8220;selection&#8221; with model key path of &#8220;self&#8221;. I don&#8217;t believe this is documented anywhere, but using &#8220;self&#8221; clears up a whole world of heartache and gives you the actual NSTreeNode instead of the NSTreeControllerProxyObject.</p>
<h3>Interface Builder</h3>
<p>It took some getting used to, but recall that you have to drop a NSObject (blue cube) from the IB Library and set the custom class to initiate an object in IB 3. The old method of &#8220;Initiate Class&#8221; or whatever from the menu isn&#8217;t available. Also remember that IB Palettes don&#8217;t work with IB 3, you will need to find (or create) IB Plugins.</p>
<h3>Core Animation</h3>
<p>Recall that the -orderIn and -orderOut options in IB are for adding and removing subviews to the selected view in IB (-setWantsLayer:YES). So NSTabView will not magically transition views in and out unless you are programatically creating new tabs and such.</p>
<p>That was just a quick list of the headache I endured over the last few weeks adjusting to Leopard and mainly spending lots of time with trees in Cocoa.</p>
<p>I&#8217;d love to hear your thoughts about ObjC 2.0 additions, whether it&#8217;s garbage collection or something more minute!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/12/29/objective-c-20-and-leopard-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HUD Controls in Leopard</title>
		<link>http://www.macfanatic.net/blog/2007/11/29/hud-controls-in-leopard/</link>
		<comments>http://www.macfanatic.net/blog/2007/11/29/hud-controls-in-leopard/#comments</comments>
		<pubDate>Thu, 29 Nov 2007 06:53:36 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/11/29/hud-controls-in-leopard/</guid>
		<description><![CDATA[So I have finally found about 30 minutes of free time to just have fun with XCode 3, Objective-C 2, Interface Builder 3 and the like all bundled in Leopard. I&#8217;m extremely impressed with all the improvements made to the development suite, minus one major shortcoming: HUD Controls. HUD (Heads Up Display) are those gorgeous [...]]]></description>
			<content:encoded><![CDATA[<p>So I have finally found about 30 minutes of free time to just have fun with XCode 3, Objective-C 2, Interface Builder 3 and the like all bundled in Leopard.  I&#8217;m extremely impressed with all the improvements made to the development suite, minus one major shortcoming: HUD Controls.</p>
<p>HUD (Heads Up Display) are those gorgeous black windows that have started popping up all over Mac applications.  Especially in iPhoto and Aperture, as well as Pages and more, these beautiful windows serve a specific purpose.  Apple went so far as to finally include a HUD window in Interface Builder, so that developers don&#8217;t have to use a hacked together version (Interface Designers like uniformity, so it is better when everyone is using the same thing vs 15 different versions of the same window, which is the case now).  So, I naturally assumed that Apple also provided HUD versions of buttons, lists, and more, to match this window.  </p>
<p>I was wrong.</p>
<p><img src='http://www.macfanatic.net/blog/wp-content/uploads/2007/11/picture-2.png' alt='picture-2.png' /><img src='http://www.macfanatic.net/blog/wp-content/uploads/2007/11/picture-3.png' alt='picture-3.png' /></p>
<p>I can create this nice window with no effort now, but as soon as I place something on it, it looks stupid.  The simple screenshots above illustrates the effect.  (Also notice the differences in the window itself.  See how big of a difference there is just on the lines at the bottom right of the window where you resize?  Now imagine that every time I had to write an application, I had to make this from scratch.  With all the Mac developers out there, you can imagine that there are lots of variations).  I sure hope that Apple fixes this soon and doesn&#8217;t wait until 10.6 and a new window style to add this for developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/11/29/hud-controls-in-leopard/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>iSight Barcode Scanner Code</title>
		<link>http://www.macfanatic.net/blog/2007/07/30/isight-barcode-scanner-code/</link>
		<comments>http://www.macfanatic.net/blog/2007/07/30/isight-barcode-scanner-code/#comments</comments>
		<pubDate>Tue, 31 Jul 2007 01:43:01 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/07/30/isight-barcode-scanner-code/</guid>
		<description><![CDATA[I ran across another Mac shareware team I&#8217;d never heard of, Bruji, makers of the &#8220;Pedia&#8221; software, such as Bookpedia, CDPedia, and DVDPedia. Looks a lot like Delicious Library, except split up into different applications. What is interesting here is the little gem I found on the website in some sample code and open-source frameworks. [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across another Mac shareware team I&#8217;d never heard of, <a href="http://www.bruji.com" target="_blank">Bruji</a>, makers of the &#8220;Pedia&#8221; software, such as Bookpedia, CDPedia, and DVDPedia.  Looks a lot like Delicious Library, except split up into different applications.</p>
<p>What is interesting here is the little gem I found on the website in some sample code and open-source frameworks.  The Bruji team released a framework allowing Cocoa developers to grab barcodes from an internal or external iSight or other firewire camera.</p>
<p class="download">Download the source <a href="http://www.bruji.com/cocoa/barcode.html" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/07/30/isight-barcode-scanner-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Look at Leopard</title>
		<link>http://www.macfanatic.net/blog/2007/06/13/a-look-at-leopard/</link>
		<comments>http://www.macfanatic.net/blog/2007/06/13/a-look-at-leopard/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 15:52:17 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/06/13/a-look-at-leopard/</guid>
		<description><![CDATA[Jobs faced a very tough audience this past Monday as he delivered his keynote speech to over 5000 attendees at Appleâ€™s annual World Wide Developers Conference. With the previous announcement of the iPhone and the delay for Leopard, everyone was wondering what Jobs would pull out of his box of tricks this time. Sadly enough, [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Jobs faced a very tough audience this past Monday as he delivered his keynote speech to over 5000 attendees at Appleâ€™s annual World Wide Developers Conference.<span>  </span>With the previous announcement of the iPhone and the delay for Leopard, everyone was wondering what Jobs would pull out of his box of tricks this time.<br />
<o:p></o:p><br />
Sadly enough, this WWDC wasn&#8217;t quite as exciting as we&#8217;d been led to believe.<span>  </span>At last year&#8217;s conference, I was thrilled with several of these features and spent a week in hands-on sessions learning about the technologies.<span>  </span>Therefore, most of this was a repeat for me.<span>  </span>I had still held out hope for the &quot;secret&quot; features to be announced.<span>  </span>There were a few new features announced, but nothing that blew me away like I was expecting.<span>  </span>However, Leopard is a huge release and should thrive for several years.<span>  </span>It will really shine once we start seeing applications that are Leopard-only.<span>  </span>The possibilities are simply amazing.<span>  </span>Letâ€™s discuss some of the finer points of Leopard.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><strong>Multicore Support</strong><strong><o:p></o:p></strong></p>
<p class="MsoNormal">This is a major improvement for all Intel Mac users.<span>  </span>Even first generation Macbook users and all the early Intel adopters should see performance gains in Leopard.<span>  </span>Tiger was designed to run on one-core processors, which was fine at the time.<span>  </span>However, all Intel Macs have at least 2 cores, with the high-end Mac Pro having 8 all together.<span>  </span>Can you see the reasoning here?<span>  </span>With Leopard optimized to make the best use of all those cores, and new ways for developers to further improve their programs (<a href="http://www.apple.com/macosx/leopard/technology/multicore.html" target="_blank">read more about NSOperation and NSOperationQueue</a> <span class="apple-style-span"></span>), Leopard should see a significant performance improvement.</p>
<p><strong>Safari 3 for Windows</strong></p>
<p>I&#8217;m not sure if Safari 3 for Windows is a secret feature of Leopard or not.  I&#8217;m actually using the beta on Windows right now to write this article and so far it has behaved itself rather nicely.  The attention to detail in making Safari for Windows just like Safari on Mac is incredible.  Even the contextual menu (right-click) gives you the same options, such as &quot;Save Image to Desktop&quot;.  I mean, that&#8217;s just crazy.</p>
<p><strong>Boot Camp</strong></p>
<p class="MsoNormal">Most were hoping for Jobs to announce some amazing virtualization technology built right in to Leopard.<span>  </span>Iâ€™m rather glad that this approach wasnâ€™t taken for a few reasons.<span>  </span>First, there are already two options on the market today: Parallels and VMWare.<span>  </span>Parallels has proven they are dedicated to providing new features and constantly improving the software.<span>  </span>I love Apple, but if they incorporated virtualization into Leopard, the updates would be few and far between when compared to Parallels.<span>  </span><em>Just check out Parallels new 3.0 release to get what I mean.<o:p></o:p></em></p>
<p class="MsoNormal">What Jobs did tell us is that Boot Camp will allow you to switch between Windows and Leopard faster.<span>  </span>Quick example: If you&#8217;re in Leopard and need to switch to Windows, be sure to use the Restart in Windows option from the Apple Menu.<span>  </span>This will place Leopard into a hibernating state and, if youâ€™ve previously used Windows, should start Windows from where you left off.<span>  </span>This will make the process much more relatable to Suspending a virtual machine in Parallels.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong>New Desktop <o:p></o:p></strong></p>
<p class="MsoNormal">The redesigned Desktop is touted as the number one feature for Leopard.<span>  </span>However, I donâ€™t see anything revolutionary or amazing about it.<span>  </span></p>
<ul style="margin-top: 0in" type="disc">
<li class="MsoNormal">The      Menu Bar has a new look.<span>  </span>Itâ€™s very      comparable to the trashy-translucent taskbar in <st1:place w:st="on">Vista</st1:place>.<span>  </span>Iâ€™m not excited, but Iâ€™ll put my      concerns aside until I see it in person.<span>       </span></li>
<li class="MsoNormal">The      Dock has seen a facelift.<span>  </span>Your      icons now sit on a silver background that reflects any window behind it,      making it look 3D.<span>  </span>Might look cool,      but is that really a feature?<span>  </span></li>
<li class="MsoNormal">No      blue background.<span>  </span>Iâ€™m very sad.<span>  </span>For me, the Mac experience has always      included a new, cool Aqua background with every major release.<span>  </span>Jobs explicitly stated that no one ever      uses these and itâ€™s a waste of time.<span>       </span>I like them Steve!</li>
<li class="MsoNormal">Anyone      else notice that the hard drive icon wasnâ€™t on the Desktop.<span>  </span>Very minimalist look.</li>
<li class="MsoNormal">Stacks.<span>  </span>Iâ€™m actually fairly excited about this      new feature.<span>  </span>Basically, itâ€™s a way to organize your files and preview the contents in a cool new way, without opening a Finder window.<span>  </span>This was      originally rumored to be included in Panther, then in Tiger, and now in      Leopard.<span>  </span>Nice to see it finally      made it in.<span>  </span>All the demos show the      stacks being used in the Dock.<span>  </span>I      wonder if weâ€™ll be able to use them other places.<span>  </span>I love the concept, but wonâ€™t use it      that much if I have to use them only in the Dock.</li>
</ul>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"> <img src="http://www.macfanatic.net/blog/wp-content/uploads/2007/06/07leopardscreen.jpg" alt="Leopard Desktop" width="675" /></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p><span id="more-1029"></span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong>EA Games <o:p></o:p></strong></p>
<p class="MsoNormal">Not really a feature of Leopard itself, but an important announcement for the Mac anyway.<span>  </span>Traditionally, game titles were released for console and PC and then ported over to Mac several months later, if at all.<span>  </span>EA announced during the keynote that they are committed to delivering new titles to the Mac alongside the console and PC releases.<span>  </span>As time progresses, the Mac should shun its reputation as the â€œnon-gamingâ€ platform.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong>Core Animation</strong></p>
<p class="MsoNormal">Remember when I said we would are going to see some awesome applications that are built as Leopard-only?  The main reason for that is this technology right here.  Core Animation let&#8217;s developers create very fluid, interactive, and attractive interfaces with ease.  There were several demos of the technology at WWDC last year and I&#8217;m sure it&#8217;s a main focus this year as well.  A quick example was given in Monday&#8217;s keynote.  If you&#8217;ve ever seen the AppleTV intro movie, you&#8217;re on the right track.  Very cool applications will follow.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong>Improved Developer Tools</strong></p>
<p>The mac is only as strong as its developers and Apple realizes this.  So with Leopard, developers get a XCode 3, sporting tons of new features including refactoring (even in nib files) and function collapsing, XRay for seeing exactly what your app is doing at any time, DTrace, Dashcode for creating widgets, and Interface Builder 3.  All of those mentioned are huge updates and improvements, and XRay and Dashcode are new applications all together.  XRay will make performance tuning your applications so much easier.  I love you Apple!</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong>Back to my Mac<o:p></o:p></strong></p>
<p class="MsoNormal">Dot Mac didnâ€™t see any other improvements besides this one feature as far as I can tell.<span>  </span>Basically, you enable a setting on all your Macs and those computers talk with the dot Mac service.<span>  </span>Then, if youâ€™re on the road with your laptop and realize that you need something off any of your other computers, you fire up the Finder and they appear in the sidebar for you.<span>  </span>Works just like youâ€™re on your home network.<span>  </span>Details havenâ€™t been released about the service working with firewalls or routers.<span>  </span>Iâ€™d imagine an Airport Base Station update might introduce this functionality at a later time.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><strong>New Finder<o:p></o:p></strong></p>
<p class="MsoNormal">I think everyone was hoping for a new Finder.<span>  </span>I personally feel disappointed however.<span>  </span>The Finder does have a new interface, but then again, itâ€™s not new.<span>  </span>Itâ€™s just iTunes for your files.<span>  </span>Coverflow in the Finder looks remotely useful, but Iâ€™m not sure just how much Iâ€™ll use it.<span>  </span>The overall appearance seems a little drab, especially if youâ€™re already not a fan of the iTunes 7 look.<span>  </span>That look will be everywhere in Leopard.<span>  </span>No hiding.<span>  </span>It will find you.<span>  </span>Also of note is a report that the new Finder is the first one to be scrapped and written in <st1:city w:st="on"><st1:place w:st="on">Cocoa</st1:place></st1:city>.<span>  </span>And because of the multitude of updates to <st1:city w:st="on"><st1:place w:st="on">Cocoa</st1:place></st1:city>, including multicore and 64-bit support, performance is drastically improved.<span>  </span>At least that part is welcome.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><strong>Spaces<o:p></o:p></strong></p>
<p class="MsoNormal">Spaces is just Appleâ€™s incarnation of a virtual desktop manager.<span>  </span>Granted itâ€™s a very nice one, but still nothing that wasnâ€™t available before Leopard (see <a href="http://www.macfanatic.net/blog/2006/04/16/virtue-and-custom-disk-images/" target="_blank">Virtue</a>).<span>  </span>Spaces will allow you to group application windows in â€œspacesâ€ so you can better organize screen clutter.<span>  </span>Itâ€™s a natural extension to Expose and should be very useful.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong><o:p> </o:p></strong></p>
<p class="MsoNormal"><strong>Quick Look<o:p></o:p></strong></p>
<p class="MsoNormal">This new technology is everywhere in Leopard.<span>  </span>If you are in the new Finder and want to quickly preview a Word, Excel, PDF, or some other common file, just tap the spacebar and a black translucent window pops up letting you scroll through the document with ease.<span>  </span>It will even let you preview pictures and movies in full screen mode.<span>  </span>Which raises the question: Will full-screen mode be enabled without Quicktime Pro in Leopard?</p>
<p class="MsoNormal"><img src="http://www.macfanatic.net/blog/wp-content/uploads/2007/06/untitled.JPG" alt="Quick Look" width="675" /></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Quick Look is a plug-in architecture so developers can easily add support for their applications, just like Spotlight plugins were everywhere after Tigerâ€™s release.<span>  </span>This will also allow these documents to work with the Finderâ€™s Cover Flow view.<span>  </span>Therefore if OminGroup releases a Quick Look plugin for OmniOutliner, you will be able to quickly preview the file without opening OmniOutlier from right within the Finder and also be able to scroll through the document in Cover Flow view.<span>  </span>Pretty cool stuff.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong><o:p> </o:p></strong></p>
<p class="MsoNormal"><strong>Time Machine<o:p></o:p></strong></p>
<p class="MsoNormal">If you havenâ€™t heard of Time Machine by now, youâ€™ve lived in a hole my friend.<span>  </span>Basically, this is Appleâ€™s very pretty way of dealing with backup software.<span>  </span>You attach an external disc, Leopard asks if you want to enable Time Machine, and from there youâ€™re all set.<span>  </span>If youâ€™re ever missing a file, start Time Machine and you get this spacial 3D view of your files and once you locate the old file, you just â€œrecoverâ€ it to the present.<span>  </span>Very easy representation and should be accessible to more users as well.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong><o:p> </o:p></strong></p>
<p class="MsoNormal"><strong>Front Row and DVD Player<o:p></o:p></strong></p>
<p class="MsoNormal">These werenâ€™t talked about in the keynote, but are mentioned on the Apple website.<span>  </span>Front Row is now like the AppleTV interface.<span>  </span>Iâ€™m not quite as excited because I find the current Front Row interface to be superior to the one in the AppleTV, but thatâ€™s the update.<span>  </span>DVD player also sports more HUD style windows and several new features for bookmarking playback and more.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong><o:p> </o:p></strong></p>
<p class="MsoNormal"><strong>Parental Controls<o:p></o:p></strong></p>
<p class="MsoNormal">Parental controls have been beefed up in Leopard as well.<span>  </span>Now Leopard can filter out websites based on content and parents can set time limits on the computer.<span>  </span>The time limits can be based on usage, say a one hour limit, and also for times the child can use the computer.<span>  </span>Useful for setting bedtimes and such.<span>  </span>Iâ€™m not sure if <st1:place w:st="on">Vista</st1:place> has anything like this or not.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong><o:p> </o:p></strong></p>
<p class="MsoNormal"><strong>Photo Booth <o:p></o:p></strong></p>
<p class="MsoNormal">If you read the fine print, Photo Booth has seen some updates as well.<span>  </span>There are more effects to use on your pictures, backdrops, â€œburstâ€ pictures, and Photo Booth now does video too.<span>  </span>The â€œburstâ€ pictures are a quick series of 4 pictures in succession which can be made into an animation. <span> </span>And the fact that Photo Booth does video is just cool.<span>  </span>Applying all those effects to your video in a snap will be even more fun at parties!</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><strong><o:p> </o:p></strong></p>
<p class="MsoNormal"><strong>iChat<o:p></o:p></strong></p>
<p class="MsoNormal">iChat has seen some major updates, many of those mentioned above in Photo Booth.<span>  </span>Backdrops, like sitting in front of a green-screen, are a touted feature.<span>  </span>Photo Booth effects are now supported in iChat as well as tabbed chats to clean up window clutter.<span>  </span>iChat Theater is a new technology that lets you share photos, presentations and more in a video chat, just like if you were giving a Keynote presentation in person.<span>  </span>Also of note is the following text from the Apple website: â€œ<span class="apple-style-span"><span style="font-size: 9pt">Chat works with AIM, the largest instant messaging community in the <st1:country-region w:st="on"><st1:place w:st="on">U.S.</st1:place></st1:country-region> You and your buddies can be either AIM or .Mac users. Text, audio, and video chat whether your buddies use a Mac or PC. Sign in with your AIM account and all your buddies appear in your iChat buddy list</span></span>â€.<span>  </span>Does the Tiger version of iChat support video and audio chats with PC users?<span>  </span>Iâ€™m pretty sure it doesnâ€™t and this is a very welcome feature!</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><strong>Conclusion<o:p></o:p></strong></p>
<p class="MsoNormal">There are several other features that I didnâ€™t discuss, such as the new Mail and iCal.<span>  </span>You can read more on all the features in Leopard <a href="http://www.apple.com/macosx/leopard/features/" target="_blank">here</a>.<span>  </span>The Apple website has finally seen a facelift and looks fairly impressive, so check that out as well.<span>  </span>If youâ€™re interested, the WWDC keynote is available online and there are several videos and images showing the new applications and features available in Leopard.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Let me know your impressions about Leopard.<span>  </span>With only a few months until the release, we are in the final stretch.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/06/13/a-look-at-leopard/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Quick Cocoa Tip</title>
		<link>http://www.macfanatic.net/blog/2007/03/28/quick-cocoa-tip/</link>
		<comments>http://www.macfanatic.net/blog/2007/03/28/quick-cocoa-tip/#comments</comments>
		<pubDate>Thu, 29 Mar 2007 02:56:29 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/03/28/quick-cocoa-tip/</guid>
		<description><![CDATA[It took me a good 20 minutes to run down and find this bug in my code and I honestly can&#8217;t believe that it hasn&#8217;t come up before now. I thought that I would share in case anyone out there is banging their head against the table like I was. I have a class called [...]]]></description>
			<content:encoded><![CDATA[<p>It took me a good 20 minutes to run down and find this bug in my code and I honestly can&#8217;t believe that it hasn&#8217;t come up before now.  I thought that I would share in case anyone out there is banging their head against the table like I was.</p>
<p>I have a class called MBHand that contains a NSMutableArray as one of the key objects.  So, on init, I need to set that array up to use.  I thought I had that setup right.  The error crept in with the following message:</p>
<p>-[NSCFArray addObject:]: mutating method sent to immutable object</p>
<p>Got to thinking and that leads back to my init method.  I looked at my code and I had used the rather normal way of</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setArray<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSMutableArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>newArray <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> array <span style="color: #002200;">!=</span> newArray <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>array release<span style="color: #002200;">&#93;</span>;
		array <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>newArray copy<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>This method looked good, but I used array = [[NSMubableArray array] retain]; and it works fine.  Therefore, it was in the setter method above.  Yep, after looking at that, it hit me.  I wasn&#8217;t making a mutable copy of the array passed it.  Needs to have &#8220;array = [newArray mutableCopy]; &#8221; and it works like a charm!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setArray<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSMutableArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>newArray <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> array <span style="color: #002200;">!=</span> newArray <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>array release<span style="color: #002200;">&#93;</span>;
		array <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>newArray mutableCopy<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>Just a tip for all those newbies out there like me!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/03/28/quick-cocoa-tip/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Update, Photos, Software</title>
		<link>http://www.macfanatic.net/blog/2007/03/26/update-photos-software/</link>
		<comments>http://www.macfanatic.net/blog/2007/03/26/update-photos-software/#comments</comments>
		<pubDate>Mon, 26 Mar 2007 22:29:56 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Site Related]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/03/26/update-photos-software/</guid>
		<description><![CDATA[I haven&#8217;t made hardly any posts in the last several weeks and wanted to give some just general news and updates to hold everyone over for awhile. A lot has happened with the Mac community in the last month or so, I don&#8217;t have the time or memory to accurately recall everything that has transpired. [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t made hardly any posts in the last several weeks and wanted to give some just general news and updates to hold everyone over for awhile.</p>
<p>A lot has happened with the Mac community in the last month or so, I don&#8217;t have the time or memory to accurately recall everything that has transpired.  Of note, however, is that the AppleTVs have shipped and Leopard should be ready for a release within the next few months.  Something worth getting excited over!</p>
<p>School and just life in general has been pretty insane these last few weeks.  Everything is starting to die down a bit, but I&#8217;m trying to take some more personal time to just enjoy life than I have in the past, and that tends to be very time consuming in itself.  I have had some time to tie up a lot of loose ends and get started in a few other areas, and I&#8217;d like to share that.</p>
<p><strong>Photos</strong><br />
I&#8217;m working through a basic photography book and looking to book a class this summer on photography.  I have also been using Aperture for several months now and it has been in the queue for a review.  Since it will still be several weeks before I get around to reviewing it, I just thought I would say that it is an incredible piece of software and I especially love the vaults feature.  More to come on that topic later.  I have posted a gallery of my favorite pictures from my trip to Charleston, SC as well as some other general photos I like online.  <a href="http://www.macfanatic.net/images/spring_break_07/">You can view those here</a>.  Paul, I&#8217;d especially like any comments as you have a photography blog of your own.</p>
<p><strong>Software<br />
</strong>Let me just start out by saying that my current computer class has been a real challenge.  Computer Organization is the name of the game and the class focuses on digital logic, processor performance and pipelining, memory management, and the ARM assembly language.  Just to say up front, I despise writing in assembly.   Read in between the lines.  HATE it.  However, I have learned a lot and the class has been a real challenge.</p>
<p>Also of note here is that I have stopped development on Viewer and removed it from the site.  I put a lot of work into the project, but in the end it was very sloppy and poorly written.  Without the time or motivation to rework my previous work and with a lack of general interest, I&#8217;ve put it on the back burner and left it to die.  On a rainy day with time on my hands and an interest in revising and revisiting past projects, I might take it up again, but I doubt it.</p>
<p>So the good news here, I&#8217;ve started a new project!  I&#8217;ve worked through the general game-play logic and written my base code or a Phase 10-like game.  I love the card game and just went through and realized that I could create almost everything needed on my own, except for the interface.  So, in a few weeks I should have basic Terminal-based game play down and then I will embark on an adventure of learning all about custom drawing in Cocoa!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/03/26/update-photos-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Late Night Cocoa</title>
		<link>http://www.macfanatic.net/blog/2007/02/04/late-night-cocoa/</link>
		<comments>http://www.macfanatic.net/blog/2007/02/04/late-night-cocoa/#comments</comments>
		<pubDate>Mon, 05 Feb 2007 00:20:27 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/02/04/late-night-cocoa/</guid>
		<description><![CDATA[There are a few podcasts out there for Mac developers, but the one that I&#8217;ve listened to before, Cocoa Radio, was horrible. So, when I heard about a new podcast for experienced developers that wanted to learn all there is to know about Cocoa, I was pretty excited. Late Night Cocoa has just released its [...]]]></description>
			<content:encoded><![CDATA[<p>There are a few podcasts out there for Mac developers, but the one that I&#8217;ve listened to before, Cocoa Radio, was <strike>horrible</strike>.  So, when I heard about a new podcast for experienced developers that wanted to learn all there is to know about Cocoa, I was pretty excited.</p>
<p><a href="http://www.latenightcocoa.com/" target="_blank">Late Night Cocoa</a> has just released its third episode detailing the use of web services with Cocoa.  Overall this is an awesome podcast so far, getting support from major developers in the community as they guest on the show to talk about a specific subject that they are really knowledgeable about.</p>
<p class="alert">I apologize for being very rude and not backing up my comment with more reasoning.  I had listened to a show or two almost a year ago and didn&#8217;t care for it.  I have since listened to a few more episodes to make better judgement.  While I still don&#8217;t care for the show as much, that should not stop anyone from listening on their own account.  CocoaRadio has very pertinent information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/02/04/late-night-cocoa/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Viewer 2.1 Released</title>
		<link>http://www.macfanatic.net/blog/2007/01/04/viewer-21-released/</link>
		<comments>http://www.macfanatic.net/blog/2007/01/04/viewer-21-released/#comments</comments>
		<pubDate>Fri, 05 Jan 2007 03:43:34 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/01/04/viewer-21-released/</guid>
		<description><![CDATA[I have been working on this application for probably close to six months now, in my spare time that I had during this last semester. This app was inspired by a few non-tecnical friends wanting an application like this, and I took up the challenge. I&#8217;ve learned tons about Cocoa programming concepts and techniques while [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on this application for probably close to six months now, in my spare time that I had during this last semester.  This app was inspired by a few non-tecnical friends wanting an application like this, and I took up the challenge.  I&#8217;ve learned tons about Cocoa programming concepts and techniques while working through this and have enjoyed the challenge.</p>
<p>This app has been in &#8220;beta&#8221; testing for the last few months to some people that I know online.  They have used it and provided useful feedback and expressed an interest in it.  Now that the list of users has grown somewhat, I have taken up the courage to release it to the public.  Let me start off by saying that this is a controversial piece of software if there ever was one.  It will surely offend several of you for various moral reasons and because of that I don&#8217;t wish to discuss it anymore on the main page.  If your interest is intrigued, and you are not easily offended or won&#8217;t take me hostage and call me dirty names, you can read more about the application, the license agreement, and download a copy with source at the link below.</p>
<p><a href="http://www.macfanatic.net/blog/viewer/">Read more about Viewer here.<br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/01/04/viewer-21-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Key Events and the Responder Chain: Sample Code using arrow keys in custom NSTextField</title>
		<link>http://www.macfanatic.net/blog/2007/01/01/key-events-and-the-responder-chain-sample-code-using-arrow-keys-in-custom-nstextfield/</link>
		<comments>http://www.macfanatic.net/blog/2007/01/01/key-events-and-the-responder-chain-sample-code-using-arrow-keys-in-custom-nstextfield/#comments</comments>
		<pubDate>Tue, 02 Jan 2007 04:37:17 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/01/01/key-events-and-the-responder-chain-sample-code-using-arrow-keys-in-custom-nstextfield/</guid>
		<description><![CDATA[My latest adventure left me using a NSStepper to increment and decrement a NSTextField, just making the numbers go up or down by one. I set the minValue to 1 and bound the maxValue to an array controller I have, with the appropriate data. All of this works fine, including the -valueWraps behavior to always [...]]]></description>
			<content:encoded><![CDATA[<p>My latest adventure left me using a NSStepper to increment and decrement a NSTextField, just making the numbers go up or down by one.  I set the minValue to 1 and bound the maxValue to an array controller I have, with the appropriate data.  All of this works fine, including the -valueWraps behavior to always keep the value in the correct range.  However, I would like to have keyboard events do the same thing as the mouse events, so I rigged up a simple custom NSTextField that intercepts keyUp: events and conforms to the -valueWraps behavior set in the NSStepper itself.</p>
<p>Read on to see some snippets of code with an explanation and download a sample project.</p>
<p><span id="more-922"></span></p>
<div class="code">-(void)keyUp:(NSEvent *)theEvent {if ([theEvent modifierFlags] &#038; NSNumericPadKeyMask) {<br />
NSString *theArrow = [theEvent charactersIgnoringModifiers];</div>
<p>In this first bit, we are filtering out only keys pressed that are part of the numeric keypad.<br />
Arrow keys fall into this category. The string is a string of keys pressed.</p>
<div class="code">if ( [theArrow length] == 0 ) {<br />
return;            // reject dead keys<br />
}if ( [theArrow length] == 1 ) {<br />
unichar keyChar = [theArrow characterAtIndex:0];</div>
<p>Now we have a char that represents the key pressed, an arrow key still</p>
<div class="code">if ( keyChar == NSUpArrowFunctionKey ) {// Setup the loop, wrapping action between bounds<br />
if ( [[self stringValue] doubleValue] &lt; [stepper maxValue] ) {<br />
NSNumber *value = [NSNumber numberWithInt:[[self stringValue] intValue] + 1];<br />
[self setStringValue:[value stringValue]];<br />
} else if ( [[self stringValue] doubleValue] &gt;= [stepper maxValue] ) {<br />
[self setStringValue:@"><br />
}<br />
}</div>
<p>The above deals with the user hitting the up arrow key and the below deals with user hitting the down arrow key</p>
<div class="code">else if ( keyChar == NSDownArrowFunctionKey ) {// Setup loop, wrapping action between bounds<br />
if ( [[self stringValue] doubleValue] &gt; 1 ) {<br />
NSNumber *value = [NSNumber numberWithInt:[[self stringValue] intValue] &#8211; 1];<br />
[self setStringValue:[value stringValue]];<br />
} else if ( [[self stringValue] doubleValue] &lt;= 1 )<br />
[self setStringValue:[NSString stringWithFormat:@&#8221;><br />
}</div>
<p>Essentially, I set a NSTextField&#8217;s custom class to my StepperTextField.  Then I set the outlet from the text field to a NSStepper I already have configured in the interface, correct with maxValue and minValue set for the NSStepper in IB.  Of note, I use the keyUp: method because the keyDown: method is being captured by the field editor inside the NSTextField, so I never catch those events.  This seemed like the simplest approach to me.  Now when the user hits a down arrow, the number will decrement by one.  An up arrow increments it by one.  If the value will be over the maxValue, it gets set to 1.  If it will be less than 1, it gets set to the maxValue.</p>
<p><a href="http://www.macfanatic.net/downloads/software/samplecode/steppertextfield.zip">Download a sample project with plenty of comments here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/01/01/key-events-and-the-responder-chain-sample-code-using-arrow-keys-in-custom-nstextfield/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Cocoa Bindings Quickie</title>
		<link>http://www.macfanatic.net/blog/2006/12/19/cocoa-bindings-quickie/</link>
		<comments>http://www.macfanatic.net/blog/2006/12/19/cocoa-bindings-quickie/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 04:04:02 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2006/12/19/cocoa-bindings-quickie/</guid>
		<description><![CDATA[Just to sweat it out, I&#8217;ve been working on adding a cool HUD-style Inspector to an app I&#8217;m working on. The thing is I&#8217;ve been doing it all by hand. As in creating the whole freaking window, text, everything on the window, from code. Not an easy process and it gives me so much appreciation [...]]]></description>
			<content:encoded><![CDATA[<p>Just to sweat it out, I&#8217;ve been working on adding a cool HUD-style Inspector to an app I&#8217;m working on.  The thing is I&#8217;ve been doing it all by hand.  As in creating the whole freaking window, text, everything on the window, from code.  Not an easy process and it gives me so much appreciation for Interface Builder!</p>
<p>The thing is I needed to bind a NSTextField to some values from an array controller.  Not that big of a deal setting them up in code, but then I decided that to simplify my life, I would need to bind them with the &#8220;displayPatternValueX&#8221; option, instead of just binding to :@&#8221;value&#8221;.  So, without further ado, here is a snippet of code that produces a single textfield on the window bound to my controller with a sorta label before the actual bound value.  It&#8217;s almost magic!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">/* Rating */</span>
<span style="color: #400080;">NSTextField</span> <span style="color: #002200;">*</span>ratingField <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSTextField</span> alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>NSMakeRect<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">10</span><span style="color: #002200;">+</span><span style="color: #2400d9;">20</span>, y_position – <span style="color: #2400d9;">20</span> – <span style="color: #2400d9;">50</span>, windowSize.width<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">2</span><span style="color: #002200;">*</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">10</span><span style="color: #002200;">+</span><span style="color: #2400d9;">20</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>, textHeight<span style="color: #002200;">+</span><span style="color: #2400d9;">5</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>window contentView<span style="color: #002200;">&#93;</span> addSubview<span style="color: #002200;">:</span>ratingField<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>ratingField setEditable<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>ratingField setSelectable<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>ratingField setFont<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSFont</span> systemFontOfSize<span style="color: #002200;">:</span>textHeight<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>ratingField setTextColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSColor</span> whiteColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#91;</span>ratingField setDrawsBackground<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>ratingField setBordered<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>ratingField setStringValue<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%{value}@ Bookmarks&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>ratingField bind<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;displayPatternValue1&quot;</span> toObject<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span>parent BookmarksController<span style="color: #002200;">&#93;</span> withKeyPath<span style="color: #002200;">:</span>@”selection.rating” options<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithObject<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Rating: %{value1}@ &quot;</span><span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span>@”NSDisplayPattern”<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>Just need to keep in mind that the magic code does what you can easily do in IB.  Just to clarify, this is in a separate NIB and I&#8217;m essentially using File&#8217;s Owner as my binding object, except I used [parent BookmarksController] to access this.  In IB I would have bound to File&#8217;s Owner with a modelKeyPath of @&#8221;BookmarksController.selection.bookmarkName&#8221; to get the same result.  Tricky part was getting the NSDictionary setup using the constant @&#8221;NSDisplayPattern&#8221; to get the pattern to work.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>ratingField bind<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;displayPatternValue1&quot;</span> toObject<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span>parent BookmarksController<span style="color: #002200;">&#93;</span> withKeyPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;selection.rating&quot;</span> options<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithObject<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Rating: %{value1}@ &quot;</span><span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;NSDisplayPattern&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>Hope that all helps someone since I can&#8217;t find any documentation on the subject online.  There&#8217;s plenty to explain it for IB, but there aren&#8217;t any examples of doing it by hand.  Thought I would throw that out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2006/12/19/cocoa-bindings-quickie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing a Spotlight Style Search Menu in Your Application</title>
		<link>http://www.macfanatic.net/blog/2006/12/14/implementing-a-spotlight-style-search-menu-in-your-application/</link>
		<comments>http://www.macfanatic.net/blog/2006/12/14/implementing-a-spotlight-style-search-menu-in-your-application/#comments</comments>
		<pubDate>Fri, 15 Dec 2006 04:38:58 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2006/12/14/implementing-a-spotlight-style-search-menu-in-your-application/</guid>
		<description><![CDATA[I thought I would share a bit of code with anyone out there who wonders exactly how basic searching is achieved in your favorite applications. Conceptually, the user will enter a search string in the search box, something like &#8220;Jo&#8221;. Now, you will need to find every object in your table that has &#8220;jo&#8221; in [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I would share a bit of code with anyone out there who wonders exactly how basic searching is achieved in your favorite applications.</p>
<p>Conceptually, the user will enter a search string in the search box, something like &#8220;Jo&#8221;.  Now, you will need to find every object in your table that has &#8220;jo&#8221; in it.  You get to choose the amount of control, as a programmer, you put into this.  If you want to be very kind, you can add a drop-down menu that the user clicks to search for &#8220;Jo&#8221; just in the name field, for example.  However, I feel that most people are comfortable enough with just filtering (ie, not full-scale searching), we will simply search every item in our object to find matches.  Still with me?</p>
<p>For example (&#8216;Por Exemplo&#8217; comes to mind..) :</p>
<p>Imagine we are creating an address book-like app (hint-hint) and each person in our address book has four pieces of data each.  Each person has a name, a screen name, an url, and an image associated with them.  We certainly can&#8217;t filter the images, but we would like to search through the names, screen names, and urls.  So, let&#8217;s figure out what we&#8217;re going to do.</p>
<p>First, you&#8217;re going to setup your interface in IB.  I&#8217;m not going to take the time to go through all of this, but you drop a NSSearchField onto your window and hook up the bindings with the &#8220;predicate&#8221; option farther down the Inspector window.  I have an array controller of &#8220;Person&#8221; objects, so I want to set my bindings as &#8220;PeopleController&#8221; as my source (same as the data source for my tableview), filterPredicate, and the model key as &#8220;personName&#8221; (the string that holds the name in a Person object, doesn&#8217;t really matter, but you must fill in a valid KVC value here).</p>
<p>I have also subclassed out the standard NSArrayController to provide filtering support.  I connect my &#8220;search&#8221; IBAction to my NSSearchField, to actually implement the searching.  I also like the instant filtering style, so I select the &#8220;Sends Search String Immediately&#8221; attribute in IB for my NSSearchField.</p>
<p>That ties up the interface stuff, now we need to actually figure out how we are going so sort.  The concept behind this is we go through every object in the original array (that supplies the table) and see if it matches our search criteria.  If it does match, we&#8217;ll throw it into a new array.  When we&#8217;ve searched everything, we&#8217;ll return this array to the table so it can display it as the search results.  When the user is done searching, we release that array and return the table back to the original array that holds all of our data.  Let&#8217;s start searching!</p>
<h2>Code for the filtering Array Controller</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>search<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>self setSearchString<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>sender stringValue<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>self rearrangeObjects<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>arrangeObjects<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>objects <span style="color: #002200;">&#123;</span>
&nbsp;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> searchString <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span> || <span style="color: #002200;">&#91;</span>searchString isEqualToString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		newObject <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
		<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>super arrangeObjects<span style="color: #002200;">:</span>objects<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">/*
		Create array of objects that match search string.
		Also add any newly-created object unconditionally:
		(a) You’ll get an error if a newly-added object isn’t added to arrangedObjects.
		(b) The user will see newly-added objects even if they don’t match the search term.
	*/</span>
&nbsp;
	<span style="color: #400080;">NSMutableArray</span><span style="color: #002200;">*</span> matchedObjects <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableArray</span> arrayWithCapacity<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>objects count<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// case-insensitive search</span>
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>lowerSearch <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>searchString lowercaseString<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #400080;">NSEnumerator</span> <span style="color: #002200;">*</span>oEnum <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>objects objectEnumerator<span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">id</span> item;
&nbsp;
	<span style="color: #a61390;">while</span> <span style="color: #002200;">&#40;</span>item <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>oEnum nextObject<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
		<span style="color: #11740a; font-style: italic;">// if the item has just been created, add it unconditionally</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>item <span style="color: #002200;">==</span> newObject<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			<span style="color: #002200;">&#91;</span>matchedObjects addObject<span style="color: #002200;">:</span>item<span style="color: #002200;">&#93;</span>;
			newObject <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
		<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
&nbsp;
			<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>lowerName <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>item valueForKeyPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;personName&quot;</span><span style="color: #002200;">&#93;</span> lowercaseString<span style="color: #002200;">&#93;</span>;
			<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>lowerScreenName <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>item valueForKeyPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;personScreenName&quot;</span><span style="color: #002200;">&#93;</span> lowercaseString<span style="color: #002200;">&#93;</span>;
			<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>lowerUrl <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>item valueForKeyPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;personUrl&quot;</span><span style="color: #002200;">&#93;</span> lowercaseString<span style="color: #002200;">&#93;</span>;
&nbsp;
			<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> lowerName <span style="color: #002200;">!=</span> <span style="color: #a61390;">NULL</span> <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#91;</span>lowerName rangeOfString<span style="color: #002200;">:</span>lowerSearch<span style="color: #002200;">&#93;</span>.location <span style="color: #002200;">!=</span> NSNotFound<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
				<span style="color: #002200;">&#91;</span>matchedObjects addObject<span style="color: #002200;">:</span>item<span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> lowerScreenName <span style="color: #002200;">!=</span> <span style="color: #a61390;">NULL</span> <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#91;</span>lowerScreenName rangeOfString<span style="color: #002200;">:</span>lowerSearch<span style="color: #002200;">&#93;</span>.location <span style="color: #002200;">!=</span> NSNotFound <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
				<span style="color: #002200;">&#91;</span>matchedObjects addObject<span style="color: #002200;">:</span>item<span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> lowerUrl <span style="color: #002200;">!=</span> <span style="color: #a61390;">NULL</span> <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#91;</span>lowerUrl rangeOfString<span style="color: #002200;">:</span>lowerSearch<span style="color: #002200;">&#93;</span>.location <span style="color: #002200;">!=</span> NSNotFound <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
				<span style="color: #002200;">&#91;</span>matchedObjects addObject<span style="color: #002200;">:</span>item<span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#125;</span>
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>super arrangeObjects<span style="color: #002200;">:</span>matchedObjects<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>The code above goes through each object in the array and pulls out a string for the name, url, and screen name.  It compares the entered search string to each of those strings, and if it matches, adds it to the array we return that has the matchedObjects.  Of note here is that we check for a NULL string from the object because if we don&#8217;t, the object will show up in the results even though it shouldn&#8217;t.</p>
<p>I think that was enough of an intro to searching.  Let me know if you would like to hear more about implementing the &#8216;Recent Search Items&#8217; list, or searching by category.  Comments are welcome.  If you&#8217;re interested in a working XCode project with the code, let me know and I might throw one together and post it online.</p>
<p>UPDATE:  I didn&#8217;t originally provide enough information about this controller, so here are a few links and documentation.  Apple has documentation on this subject with almost the identical sample code that is published by mmalc below.  <a target="_blank" href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Tasks/filtering.html">You can read the documentation here</a>.</p>
<p><a href="http://homepage.mac.com/mmalc/CocoaExamples/FilteringController.zip">Download mmalc&#8217;s source (pretty much what is in the documenation) here</a>.Â  This is a sample project, so it&#8217;s nice to look at as well.Â  Of note, if you want the iTunes, Spotlight-like behavior of instant results (a true &#8220;filtering&#8221; action, vs searching), go into Interface Builder, select the NSSearchField and for it&#8217;s attributes, check the box with &#8220;Sends search string immediately&#8221;.Â  A nice example.  Check out <a target="_blank" href="http://homepage.mac.com/mmalc/CocoaExamples/controllers.html">his website with lots of other good bindings related examples is here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2006/12/14/implementing-a-spotlight-style-search-menu-in-your-application/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Some fun with NSNumbers</title>
		<link>http://www.macfanatic.net/blog/2006/12/05/some-fun-with-nsnumbers/</link>
		<comments>http://www.macfanatic.net/blog/2006/12/05/some-fun-with-nsnumbers/#comments</comments>
		<pubDate>Tue, 05 Dec 2006 05:03:56 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Humor]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2006/12/05/some-fun-with-nsnumbers/</guid>
		<description><![CDATA[I have an application that I work on just for kicks, adding new &#8220;features&#8221; and discovering how things work with Cocoa. Today I tackled one of my larger fears to date; NSNumber. I&#8217;m sure there are some seasoned Cocoa programmers out there wondering about my confusion over this class, but it was kinda scary. I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>I have an application that I work on just for kicks, adding new &#8220;features&#8221; and discovering how things work with Cocoa.  Today I tackled one of my larger fears to date; NSNumber.</p>
<p>I&#8217;m sure there are some seasoned Cocoa programmers out there wondering about my confusion over this class, but it was kinda scary.  I&#8217;m very comfortable writing plain C and feel very powerful because I know what is going on and if I get a little stumped, I can always hack something homemade together.  That&#8217;s not really the way it is a lot of times with Cocoa, there is so much already available you don&#8217;t have to hack it together and it would be better if you didn&#8217;t.  So back to NSNumbers.</p>
<p>Just to get your brains working this morning, here was a preview if() statement I had in my code, just checking to see if the number that the user entered in an NSTextField was of appropriate range.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span>startingValue intValue<span style="color: #002200;">&#93;</span> &gt;<span style="color: #002200;">=</span> <span style="color: #2400d9;">300</span> || startingValueInt &lt;<span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// Do something</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>This doesn&#8217;t seem too bad at all to me.  I need the value to be between 1 and 300.  However, I decided to get a bit more specific with my code and created an NSArray of NSNumbers holding the upper limits to check against in each specific case.  This was used to add that in the Category object itself and then you come up with the following if statement, if you will:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// This was just a very lengthy way of using NSNumbers to make sure that the entered value was in proper range</span>
<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span>startingValueInt<span style="color: #002200;">&#93;</span> compare<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>categories objectAtIndex<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span>CategoriesController selectionIndex<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span> categoryMaxValue<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> NSOrderedDescending || startingValueInt &lt;<span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// Do something</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>Now granted, you could still use a regular &#8220;&gt;=&#8221; operator here by calling the &#8220;- intValue&#8221; method on the NSNumbers I&#8217;m using.  However, I thought that I would go all out and even use an NSComparisonResult as well.  Just goes to show you that you can look smart and your code do nothing at all.  Another snippet of code is below for those that wondered about getting all of my NSNumbers into my Category array.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Setup another array with just the ranges for each category — This is the max array, all mins are zero</span>
<span style="color: #11740a; font-style: italic;">// Note that I have setup similar arrays holding the names and urls that I’m sticking into each Category ‘c’</span>
&nbsp;
<span style="color: #400080;">NSArray</span><span style="color: #002200;">*</span> maxes <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">445</span><span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span> <span style="color: #2400d9;">265</span><span style="color: #002200;">&#93;</span>,
	<span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">221</span><span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">106</span><span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">69</span><span style="color: #002200;">&#93;</span>,
	<span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">21</span><span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">229</span><span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">69</span><span style="color: #002200;">&#93;</span>,
	<span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">322</span><span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">266</span><span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">138</span><span style="color: #002200;">&#93;</span>,
	<span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">320</span><span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">107</span><span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">99</span><span style="color: #002200;">&#93;</span>,
	<span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">313</span><span style="color: #002200;">&#93;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Now need to create the categories, using each piece to make one, and insert it into the categories array</span>
<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>NSInteger i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i &lt; <span style="color: #002200;">&#91;</span>names count<span style="color: #002200;">&#93;</span>; i<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	c <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>Category new<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>c setCategoryUrl<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span>urls objectAtIndex<span style="color: #002200;">:</span>i<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>c setCategoryName<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>names objectAtIndex<span style="color: #002200;">:</span>i<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>c setCategoryMaxValue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>maxes objectAtIndex<span style="color: #002200;">:</span>i<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>categories insertObject<span style="color: #002200;">:</span> c atIndex<span style="color: #002200;">:</span> i<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>More Reading | <a href="http://cocoadevcentral.com/" target="_blank">Cocoa Dev Central</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2006/12/05/some-fun-with-nsnumbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

