<?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; Code</title>
	<atom:link href="http://www.macfanatic.net/blog/category/code/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>Introducing PharosPHP &#8211; PHP Development Framework</title>
		<link>http://www.macfanatic.net/blog/2011/01/02/introducing-pharosphp-php-development-framework/</link>
		<comments>http://www.macfanatic.net/blog/2011/01/02/introducing-pharosphp-php-development-framework/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 07:40:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2995</guid>
		<description><![CDATA[I&#8217;d like to introduce my first open source project, entitled PharosPHP.  PharosPHP is a lightweight Object-Oriented framework aimed at providing common and useful functionality to developers, in order to create powerful and flexible applications quickly. Overview I create custom web applications for a living and found myself needing a common toolset across projects.  I looked [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to introduce my first open source project, entitled <a href="http://www.PharosPHP.com">PharosPHP</a>.  PharosPHP is a lightweight Object-Oriented framework aimed at providing common and useful functionality to developers, in order to create powerful and flexible applications quickly.</p>
<h2>Overview</h2>
<p>I create custom web applications for a living and found myself needing a common toolset across projects.  I looked into existing frameworks such as <a href="http://kohanaframework.org/" target="_blank">Kohana</a>, <a href="http://cakephp.org/" target="_blank">CakePHP</a>, and <a href="http://codeigniter.com/" target="_blank">CodeIgnitor</a> &#8211; but ultimately found they were still slightly too complex for my needs and the level of understanding I needed to create robust and reliable applications time and again.  In addition to that, I am responsible for maintaining roughly 6 years worth of prior development work based upon an in-house framework and wanted to carry over as much of the old framework as possible to help myself and future developers in the company.</p>
<h2>PharosPHP</h2>
<p>Unfortunately, my original goal of maintaining as much of the previous code base became less and less achievable as the framework matured under my care due to the inflexibility and poor-foresight when the framework was developed several years prior.  Currently, there is roughly 20% original code/concept in the framework, but much of the philosophy for simple web application development has been preserved and improved upon.</p>
<p><a href="http://rubyonrails.org/" target="_blank">Ruby on Rails</a> and <a href="http://codeigniter.com/" target="_blank">CodeIgnitor</a> were both huge inspirations for this framework.  RoR has a very elegant, simple, &#8220;convention over configuration&#8221; approach to application development and PharosPHP adopted this approach 100%.  The framework is lightweight and transparent enough to allow developers to understand what is going on deep inside the core, but encourages developers to leave it alone and just use the defaults &#8211; application development will be faster and uniform across projects with this approach.</p>
<h2>Features</h2>
<p>The PharosPHP framework focuses on providing a core set of functionality to developers, upon which most web applications can be built quickly and reliably.  A list of the included technologies, methodologies and projects include:</p>
<ul>
<li><a href="http://www.phpactiverecord.org/" target="_blank">PHP Active Record</a></li>
<li><a href="http://jquery.com/" target="_blank">jQuery</a></li>
<li><a href="http://www.swfupload.org/" target="_blank">SWFUpload</a></li>
<li><a href="http://particletree.com/features/php-quick-profiler/" target="_blank">PHP Quick Profiler</a></li>
<li><a href="http://www.phpguru.org/downloads/Rmail/Rmail%20for%20PHP/" target="_blank">RMail</a></li>
<li><a href="http://components.symfony-project.org/yaml/" target="_blank">YAML</a></li>
<li><a href="http://code.google.com/p/php-excel-reader/" target="_blank">MSFT Excel support</a></li>
<li>Apple PLIST support</li>
<li><a href="http://tinymce.moxiecode.com/" target="_blank">TinyMCE</a></li>
</ul>
<p>These projects bring several features to PharosPHP, and in addition PharosPHP provides:</p>
<ul>
<li>MVC architecture</li>
<li>RoR style models, via PHP Active Record (requires PHP 5.3+)</li>
<li>View rendering, buffering, partials, layouts</li>
<li>Fully configurable Routing API</li>
<li>Core System Actions (Hooks) API</li>
<li>framework / application code separation</li>
<li>Authentication framework</li>
<li>Robust caching framework</li>
<li>Modules API for distributing plugins</li>
</ul>
<h2>Open Source Project</h2>
<p>PharosPHP is an open source <a href="http://github.com/macfanatic/PharosPHP" target="_blank">project hosted on GitHub</a>.  If you are interested in contributing or using PharosPHP for your next application development project, please go grab yourself a copy or get started contributing today!</p>
<h2>Get Started</h2>
<p>To get started with PharosPHP today, head on over to <a href="http://www.PharosPHP.com">http://www.PharosPHP.com</a> for more information, code examples, and documentation!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2011/01/02/introducing-pharosphp-php-development-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>10 Awful IE Bugs</title>
		<link>http://www.macfanatic.net/blog/2010/03/02/10-awful-ie-bugs/</link>
		<comments>http://www.macfanatic.net/blog/2010/03/02/10-awful-ie-bugs/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 20:10:46 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2617</guid>
		<description><![CDATA[Sadly, as a web developer, I spend a lot of time designing, coding and testing web applications in several browsers to make sure that I can get the product to as many users as possible.  Internet Explorer is always the one that causes me the most headache, hands down. Queness has an excellent post detailing [...]]]></description>
			<content:encoded><![CDATA[<p>Sadly, as a web developer, I spend a lot of time designing, coding and testing web applications in several browsers to make sure that I can get the product to as many users as possible.  Internet Explorer is always the one that causes me the most headache, hands down.</p>
<p><a href="http://www.queness.com/" target="_blank">Queness</a> has an excellent post detailing 10 awful bugs in Internet Explorer, and provides some insight and solutions to those issues.  A great read for any web developer.  After doing this job for 2 years, I still learned a few things.</p>
<p>Read the full article from Queness <a href="http://www.queness.com/post/683/10-awful-ie-bugs-and-fixes" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/03/02/10-awful-ie-bugs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tweetie2 &amp; Lessn</title>
		<link>http://www.macfanatic.net/blog/2010/03/02/tweetie2-lessn/</link>
		<comments>http://www.macfanatic.net/blog/2010/03/02/tweetie2-lessn/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 15:33:38 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2615</guid>
		<description><![CDATA[Lessn is a quick and dirty URL shortener web application from Fever and Mint developer, Shaun Inman. Lessn is an extremely simple, personal url shortener written in PHP with MySQL and mod_rewrite Shaun uses Lessn instead of popular URL shortening services available today, such as bit.ly.  Shaun has posted a short piece about configuring Tweetie2 [...]]]></description>
			<content:encoded><![CDATA[<p>Lessn is a quick and dirty URL shortener web application from Fever and Mint developer, Shaun Inman.</p>
<blockquote><p>Lessn is an extremely simple, personal url shortener written in PHP with MySQL and mod_rewrite</p></blockquote>
<p>Shaun uses Lessn instead of popular URL shortening services available today, such as bit.ly.  Shaun has posted a short piece about configuring Tweetie2 to use the custom URL shortener and be an even cooler Twitter-holic.</p>
<p>Read more about Fever, an amazing RSS feed reader application, on macfanatic <a href="http://www.macfanatic.net/blog/2009/06/17/fever-awesome-news-from-the-haveamint-com-developer/">here</a> and <a href="http://www.macfanatic.net/blog/2009/09/14/chill-pill/">here</a>.  Check Fever out directly <a href="http://feedafever.com/" target="_blank">here</a>.</p>
<p>Read more about Lessn from Shaun Inman <a href="http://www.shauninman.com/archive/2009/08/17/less_n" target="_blank">here</a>.</p>
<p>Finally, read the article on combining Tweetie 2 and Lessn <a href="http://www.shauninman.com/archive/2009/10/12/tweetie_2_and_less_n" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/03/02/tweetie2-lessn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet Explorer: Global Variables, and Stack Overflows</title>
		<link>http://www.macfanatic.net/blog/2010/03/02/internet-explorer-global-variables-and-stack-overflows/</link>
		<comments>http://www.macfanatic.net/blog/2010/03/02/internet-explorer-global-variables-and-stack-overflows/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 12:32:47 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2613</guid>
		<description><![CDATA[The Cappuccino blog has an excellent post on recursion limitations on the global &#8220;window&#8221; host object provided by all browsers, including a few attempts to get around this limitation in the Cappuccino framework and the final solution the project has settled on. It&#8217;s a great technical read and look into the mess that is Javascript: [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://cappuccino.org/" target="_blank">Cappuccino</a> blog has an excellent post on recursion limitations on the global &#8220;window&#8221; host object provided by all browsers, including a few attempts to get around this limitation in the Cappuccino framework and the final solution the project has settled on.</p>
<p>It&#8217;s a great technical read and look into the mess that is Javascript: <a href="http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/" target="_blank">Cappuccino Blog | Internet Explorer: Global Variables, and Stack Overflows</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/03/02/internet-explorer-global-variables-and-stack-overflows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upcoming iPhone Application</title>
		<link>http://www.macfanatic.net/blog/2010/02/07/upcoming-iphone-application/</link>
		<comments>http://www.macfanatic.net/blog/2010/02/07/upcoming-iphone-application/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 14:15:29 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Site Related]]></category>
		<category><![CDATA[That's What She Said Jokes]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2538</guid>
		<description><![CDATA[I&#8217;m really excited to announce that my first iPhone application, That&#8217;s What She Said Jokes, wil soon be available on the iTunes App Store! From the App Store description: That&#8217;s What She Said Jokes is the perfect companion for your iPhone or iPod Touch. Browse both user submitted and featured scenarios focusing on That&#8217;s What [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m really excited to announce that my first iPhone application, That&#8217;s What She Said Jokes, wil soon be available on the iTunes App Store!</p>
<p><a href="http://www.macfanatic.net/blog/wp-content/uploads/2010/02/upcoming-app-announcement.jpg"><img class="alignnone size-full wp-image-2539" title="upcoming-app-announcement" src="http://www.macfanatic.net/blog/wp-content/uploads/2010/02/upcoming-app-announcement.jpg" alt="" width="675" height="258" /></a></p>
<p>From the App Store description:</p>
<blockquote><p>That&#8217;s What She Said Jokes is the perfect companion for your iPhone or iPod Touch.  Browse both user submitted and featured scenarios focusing on That&#8217;s What She Said!  Get involved by submitting your own That&#8217;s What She Said funnies and commenting and rating hilarious entries submitted by others just like you!</p></blockquote>
<p>I&#8217;ll be submitting the application for review later today and then the wait is on the App Store review team.  Hopefully the app will be for sale later this week, at $0.99USD.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/02/07/upcoming-iphone-application/feed/</wfw:commentRss>
		<slash:comments>2</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>Google Drops Support for IE6</title>
		<link>http://www.macfanatic.net/blog/2010/02/03/google-drops-support-for-ie6/</link>
		<comments>http://www.macfanatic.net/blog/2010/02/03/google-drops-support-for-ie6/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 18:45:53 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2518</guid>
		<description><![CDATA[In a win for everyone the world over, Google announced it was no longer supporting Internet Explorer 6 on Friday January 29th, 2010. By no longer providing support for production products and in the development process, Google will free up more resources to innovate and provide better experiences for users.  As a developer of mostly [...]]]></description>
			<content:encoded><![CDATA[<p>In a win for everyone the world over, Google announced it was no longer supporting Internet Explorer 6 on Friday January 29th, 2010.</p>
<p>By no longer providing support for production products and in the development process, Google will free up more resources to innovate and provide better experiences for users.  As a developer of mostly web technologies, I would personally love to drop support for IE6 and move forward with HTML5.</p>
<p>Read more about the announcement on the <a href="http://googleenterprise.blogspot.com/2010/01/modern-browsers-for-modern-applications.html" target="_blank">Google Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/02/03/google-drops-support-for-ie6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Releases PHP Compiler</title>
		<link>http://www.macfanatic.net/blog/2010/02/03/facebook-releases-php-compiler/</link>
		<comments>http://www.macfanatic.net/blog/2010/02/03/facebook-releases-php-compiler/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 14:00:30 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2529</guid>
		<description><![CDATA[Facebook has just taken PHP to an entirely new level: One common way to address these inefficiencies is to rewrite the more complex parts of your PHP application directly in C++ as PHP Extensions. This largely transforms PHP into a glue language between your front end HTML and application logic in C++. From a technical [...]]]></description>
			<content:encoded><![CDATA[<p>Facebook has just taken PHP to an entirely new level:</p>
<blockquote><p>One common way to address these inefficiencies is to rewrite the more complex parts of your PHP application directly in C++ as PHP Extensions. This largely transforms PHP into a glue language between your front end HTML and application logic in C++. From a technical perspective this works well, but drastically reduces the number of engineers who are able to work on your entire application. Learning C++ is only the first step to writing PHP Extensions, the second is understanding the Zend APIs. Given that our engineering team is relatively small — there are over one million users to every engineer — we can&#8217;t afford to make parts of our codebase less accessible than others.</p></blockquote>
<p>I can&#8217;t wait to download the source to this project and really give it a go through.  As a computer science major, this interests me greatly on an academic level.  As a programmer, I&#8217;d love to see how this performs in a production environment and if I could handle the changes to my PHP development workflow.</p>
<p>The <a href="http://developers.facebook.com/news.php?blog=1&amp;story=358" target="_blank">facebook developer article explaining the changes</a> and why it is such a big deal is a great read.  Highly encourage it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/02/03/facebook-releases-php-compiler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Video Player &#8211; SublimeVideo</title>
		<link>http://www.macfanatic.net/blog/2010/01/26/html5-video-player-sublimevideo/</link>
		<comments>http://www.macfanatic.net/blog/2010/01/26/html5-video-player-sublimevideo/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 18:26:08 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2495</guid>
		<description><![CDATA[HTML5 brings a &#60;video&#62; tag to HTML, hoping to make video an open web standard that all browsers will natively support, just like the &#60;img&#62; tag currently used.  As a bonus, this should eliminate the need of using Adobe Flash for displaying video on websites. The guys over at Jilion have announced a highly experimental [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.w3schools.com/html5/html5_reference.asp" target="_blank">HTML5 brings a &lt;video&gt; tag to HTML</a>, hoping to make video an open web standard that all browsers will natively support, just like the &lt;img&gt; tag currently used.  As a bonus, this should eliminate the need of using Adobe Flash for displaying video on websites.</p>
<p>The guys over at <a href="http://jilion.com/" target="_blank">Jilion</a> have announced a highly experimental HTML5 video player called SublimeVideo.  It&#8217;s gorgeous, and allows full screen playback, complete with HUD controls.</p>
<p>Requires either Safari 4.0.4+, Google Chrome 4.0+, or Internet Explorer with Chrome Frame installed currently.</p>
<p>Check out SublimeVideo <a href="http://jilion.com/sublime/video" target="_blank">now</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/01/26/html5-video-player-sublimevideo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash on iPhone &#8211; Gordon JS Library</title>
		<link>http://www.macfanatic.net/blog/2010/01/21/flash-on-iphone-gordon-js-library/</link>
		<comments>http://www.macfanatic.net/blog/2010/01/21/flash-on-iphone-gordon-js-library/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 17:18:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=2452</guid>
		<description><![CDATA[Flash on iPhone is now a possibility.  Sort of. The Gordon JS library aims to provide a javascript interpreter to replace the Adobe Flash runtime.  The advantage is existing Adobe Flash documents will bypass the Flash runtime itself (which is what is banned from the AppStore) and instead directly execute through Javascript, which is allowed. As [...]]]></description>
			<content:encoded><![CDATA[<p>Flash on iPhone is now a possibility.  Sort of.</p>
<p>The <a href="http://paulirish.com/work/gordon/demos/" target="_blank">Gordon JS library</a> aims to provide a javascript interpreter to replace the Adobe Flash runtime.  The advantage is existing Adobe Flash documents will bypass the Flash runtime itself (which is what is banned from the AppStore) and instead directly execute through Javascript, which is allowed.</p>
<p>As a simple exercise, pull up any of the demo pages on an iPhone and you will be viewing a Flash file (.swf) embedded in an HTML page, that runs with Javascript and works perfectly on iPhone.  Very interesting idea and the best part is, it&#8217;s open source on GitHub!</p>
<p>Worth noting, this project is in very early stages as is certainly not ready for a production environment.</p>
<p><a href="http://github.com/tobeytailor/gordon/" target="_blank">Git Source</a></p>
<p><a href="http://paulirish.com/work/gordon/demos/" target="_blank">Gordon Project Page &amp; Demos</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2010/01/21/flash-on-iphone-gordon-js-library/feed/</wfw:commentRss>
		<slash:comments>1</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>Parcycle: A Particle System with HTML5 canvas</title>
		<link>http://www.macfanatic.net/blog/2009/12/09/parcycle-a-particle-system-with-html5-canvas/</link>
		<comments>http://www.macfanatic.net/blog/2009/12/09/parcycle-a-particle-system-with-html5-canvas/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 23:29:34 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1945</guid>
		<description><![CDATA[This was a very cool find, from both a user standpoint as well as from a computer scientist standpoint.  Simply put, this particle simulator revivals Flash. Listed below are a ton of links showcasing the Particle System, HTML 5 canvas tag, and more. Parcycle &#124; A Particle System with HTML 5 Canvas Parcycle Demo HTML [...]]]></description>
			<content:encoded><![CDATA[<p>This was a very cool find, from both a user standpoint as well as from a computer scientist standpoint.  Simply put, this particle simulator revivals Flash.</p>
<p>Listed below are a ton of links showcasing the Particle System, HTML 5 canvas tag, and more.</p>
<p><a href="http://www.mrspeaker.net/2009/12/03/particle-system-with-html5-canvas/" target="_blank">Parcycle | A Particle System with HTML 5 Canvas</a></p>
<p><a href="http://www.mrspeaker.net/dev/parcycle/" target="_blank">Parcycle Demo</a></p>
<p><a href="http://en.wikipedia.org/wiki/Canvas_(HTML_element)" target="_blank">HTML 5 Canvas tag</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/12/09/parcycle-a-particle-system-with-html5-canvas/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>Excluding Category from WordPress RSS Feed</title>
		<link>http://www.macfanatic.net/blog/2009/11/30/excluding-category-from-wordpress-rss-feed/</link>
		<comments>http://www.macfanatic.net/blog/2009/11/30/excluding-category-from-wordpress-rss-feed/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 01:54:40 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1737</guid>
		<description><![CDATA[There are a few WordPress plugins available that allow you to simply exclude posts from a certain category in your RSS feed, but I ran across the code that actually does the heavy lifting and wanted to share. In your template directory, create a file (functions.php) if it doesn&#8217;t exist and place the following code [...]]]></description>
			<content:encoded><![CDATA[<p>There are a few WordPress plugins available that allow you to simply exclude posts from a certain category in your RSS feed, but I ran across the code that actually does the heavy lifting and wanted to share.</p>
<p>In your template directory, create a file (functions.php) if it doesn&#8217;t exist and place the following code in the file:</p>

<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="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">function</span> remove_press_releases<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_feed</span>  <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cat'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'-20'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'remove_press_releases'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Make note to change the number to the catID (category id) of the category, or categories, you want to exclude.  This hook is called when preparing the posts to go to the template &#8211; so we are only filtering out if it&#8217;s the RSS feed in my case.</p>
<p>If you want a lot of heavy lifting without the coding (including the Google Sitemap XML integration, excluding categories/tags from search results and more) check out the <a target="_blank" href="http://wordpress.org/extend/plugins/advanced-category-excluder/">ACE plugin</a>.</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/11/30/excluding-category-from-wordpress-rss-feed/feed/</wfw:commentRss>
		<slash:comments>0</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>Podpress and WordPress 2.5+ Bugs</title>
		<link>http://www.macfanatic.net/blog/2009/09/04/podpress-and-wordpress-2-5-bugs/</link>
		<comments>http://www.macfanatic.net/blog/2009/09/04/podpress-and-wordpress-2-5-bugs/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 13:00:54 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1507</guid>
		<description><![CDATA[I don&#8217;t upgrade Podpress very often because it is usually a very painful process. I&#8217;m debating just removing it all together as I haven&#8217;t published a podcast episode in 2 years. For a few releases of WordPress now, I&#8217;ve had javascript errors on the page for editing a post, so that I can&#8217;t upload/insert media, [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t upgrade Podpress very often because it is usually a very painful process.  I&#8217;m debating just removing it all together as I haven&#8217;t published a podcast episode in 2 years.</p>
<p>For a few releases of WordPress now, I&#8217;ve had javascript errors on the page for editing a post, so that I can&#8217;t upload/insert media, change the publication date, etc.  I found on the WordPress forums a quick fix that didn&#8217;t require me upgrading the plugin.</p>
<p>Navigate to {BLOG}/wp-content/plugins/podpress/podpress_admin_postedit.js and insert a &#8220;/*&#8221; at the top of the file and a &#8220;*/&#8221; at the bottom to comment out all the code there.  Save and reload the post edit page in your browser.  No more &#8220;dbxGroup() not defined&#8221; errors and such.</p>
<p>Probably smarter to just upgrade your plugin, but this worked for me and got me on my way.</p>
<p>Read more at the <a href="http://wordpress.org/support/topic/206368">WordPress Forums</a> topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/09/04/podpress-and-wordpress-2-5-bugs/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>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>Programming Fonts</title>
		<link>http://www.macfanatic.net/blog/2009/06/15/programming-fonts/</link>
		<comments>http://www.macfanatic.net/blog/2009/06/15/programming-fonts/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 00:47:45 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2009/06/15/programming-fonts/</guid>
		<description><![CDATA[Seems like I have seen quite a few posts about fonts used for programming in the last few days.  Part of that simply might be in response to Apple&#8217;s announcement of Menlo, a replacement for the Mac&#8217;s defacto monospaced font dating all the way back to System 6, Monaco. Taking that one step further, Hive [...]]]></description>
			<content:encoded><![CDATA[<p>Seems like I have seen quite a few posts about fonts used for programming in the last few days.  Part of that simply might be in response to Apple&#8217;s announcement of Menlo, a replacement for the Mac&#8217;s defacto monospaced font dating all the way back to System 6, Monaco.</p>
<p>Taking that one step further, Hive Logic has a couple great posts showing off some truly gorgeous monospaced fonts.  Personally, I&#8217;m in love with <a href="http://www.dafont.com/monofur.font" target="_blank">Monofur</a>, <a href="http://damieng.com/blog/2007/11/14/droid-font-family-courtesy-of-google-ascender" target="_blank">Droid Sans Mono</a>, <a href="http://www.levien.com/type/myfonts/inconsolata.html" target="_blank">Inconsolata</a>, and <a href="http://www.ms-studio.com/FontSales/anonymouspro.html" target="_blank">Anonymous Pro</a>.</p>
<p>Check out the two related posts here for a total of 11 great monospaced fonts.</p>
<p><a href="http://hivelogic.com/articles/view/top-10-programming-fonts" target="_blank">Top 10 Programming Fonts</a></p>
<p><a href="http://hivelogic.com/articles/view/anonymous-pro-programming-monospace-font/" target="_blank">Anonymous Pro: A programming font with style</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/06/15/programming-fonts/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rendering iDVD Projects in Bulk</title>
		<link>http://www.macfanatic.net/blog/2009/03/07/rendering-idvd-projects-in-bulk/</link>
		<comments>http://www.macfanatic.net/blog/2009/03/07/rendering-idvd-projects-in-bulk/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 16:58:21 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1397</guid>
		<description><![CDATA[I recently came across a home project where I needed to render multiple iDVD projects, about 8 different projects in all.  And for each of those, I needed 10 copies for friends and family.  My first thought was to simply the process by creating disc images from iDVD, so that I could then open the [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a home project where I needed to render multiple iDVD projects, about 8 different projects in all.  And for each of those, I needed 10 copies for friends and family.  My first thought was to simply the process by creating disc images from iDVD, so that I could then open the disc image in Disk Utility whenever I wanted and burn multiple copies quickly.</p>
<p>I did this for the first few, but as it took about 3.5 hours per project, it was a pain to schedule, and there was a lot of wasted time at night that my MacBook could have been rendering, except that after the project finished, I couldn&#8217;t figure out how to get iDVD to start on a second one.</p>
<p>I started writing an AppleScript to automate this, and then decided to just Google for one as someone surely had thought of this before me.  Turns out there is a very nice script that allows allows you to choose the iDVD projects you want to burn, and where you want to save the disc images.  Then, away iDVD goes.</p>
<p>Very nice script to have.  <a href="http://www.macosxhints.com/article.php?story=200809060044315" target="_blank">Mac OS X Hints.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/03/07/rendering-idvd-projects-in-bulk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nifty Terminal Trick &#8211; Autocomplete</title>
		<link>http://www.macfanatic.net/blog/2009/03/05/nifty-terminal-trick-autocomplete/</link>
		<comments>http://www.macfanatic.net/blog/2009/03/05/nifty-terminal-trick-autocomplete/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 02:52:44 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1394</guid>
		<description><![CDATA[I&#8217;ve often wondered why using some Linux machines allowed me to simply press the TAB key after entering a few characters, and the terminal would suggest auto-completions for filenames in the working directory.  It&#8217;s a very handy feature and I love it, but never could figure out why it didn&#8217;t just work automatically when I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve often wondered why using some Linux machines allowed me to simply press the TAB key after entering a few characters, and the terminal would suggest auto-completions for filenames in the working directory.  It&#8217;s a very handy feature and I love it, but never could figure out why it didn&#8217;t just work automatically when I used the Terminal is OS X.</p>
<p>Turns out that you can quickly enable this feature by copying a few files according to this tip from <a href="http://www.macosxhints.com/article.php?story=20020826003806202" target="_blank">Mac OS X Hints.com</a>.</p>
<blockquote><p>% echo &#8220;source /usr/share/tcsh/examples/rc&#8221;     &gt; ~/.tcshrc<br />
% echo &#8220;source /usr/share/tcsh/examples/login&#8221;  &gt; ~/.login<br />
% echo &#8220;source /usr/share/tcsh/examples/logout&#8221; &gt; ~/.logout</p></blockquote>
<p>As far as I know, this doesn&#8217;t affect any of your settings, but I didn&#8217;t look through these provided sample shell configuration files to make sure.  All I know is that I can now TAB to auto-complete and nothing else has been broken so far.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/03/05/nifty-terminal-trick-autocomplete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Atlas &#8211; From 280North</title>
		<link>http://www.macfanatic.net/blog/2009/02/24/atlas-from-280north/</link>
		<comments>http://www.macfanatic.net/blog/2009/02/24/atlas-from-280north/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 00:15:49 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1391</guid>
		<description><![CDATA[This is big news for web developers. I&#8217;ve discussed why I absolutely love Cappuccino for web development.  It&#8217;s a modern, full featured language and API that makes writing interactive and complex web applications much simpler.  Up until this point, writing the UI for a Cappuccino application has entailed a lot of &#8220;stupid&#8221; code for layouts [...]]]></description>
			<content:encoded><![CDATA[<p>This is big news for web developers.</p>
<p>I&#8217;ve discussed why I absolutely love Cappuccino for web development.  It&#8217;s a modern, full featured language and API that makes writing interactive and complex web applications much simpler.  Up until this point, writing the UI for a Cappuccino application has entailed a lot of &#8220;stupid&#8221; code for layouts and positioning of controls.  This is acceptable for people coming from Windows programming, Linux, and even Java for the most part.  You have to write a good chunk of code for even the most basic button to be on the window.</p>
<p><a href="http://280atlas.com/" target="_blank">Atlas</a> changes that.</p>
<p><object width="437" height="293" data="http://www.viddler.com/simple_on_site/1db9bf4d" type="application/x-shockwave-flash"><param name="id" value="viddler" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent" /><param name="src" value="http://www.viddler.com/simple_on_site/1db9bf4d" /><param name="name" value="viddler" /><param name="allowfullscreen" value="true" /></object></p>
<p>For developers familiar with Apple&#8217;s own Developer Tools, Atlas is Xcode and Interface Builder combined into a web application, itself built upon Cappuccino.  You edit your CIB file, which contains your menu bar, windows, models, views and controllers.  It acts very similar to Interface Builder, in that you can simply drag from a button to a controller to set an action, or drag from a model to a view to set an outlet.  The Inspector even has most of the normal Cocoa conveniences.</p>
<p><a href="http://280atlas.com/" target="_blank">Atlas</a> is not yet available, but has been demoed in Miami.  You can head on over to the Atlas website, from the <a href="http://280north.com/" target="_blank">280 North</a> team ( who brought us <a href="http://280slides.com/" target="_blank">280 Slides</a> and <a href="http://objective-j.org/" target="_blank">Cappuccino</a>) to register on the mailing list.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2009/02/24/atlas-from-280north/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>JSCocoa Released</title>
		<link>http://www.macfanatic.net/blog/2008/10/09/jscocoa-released/</link>
		<comments>http://www.macfanatic.net/blog/2008/10/09/jscocoa-released/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 13:07:43 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/10/09/jscocoa-released/</guid>
		<description><![CDATA[From the project&#8217;s site: JSCocoa bridges Cocoa to JavascriptCore (WebKit&#8217;s JS engine). It allows you to call C code, ObjC code, use C structs, and build Javascript classes inheriting from ObjC classes. Basically, JSCocoa allows you to use Cocoa classes and the runtime, only using Javascript. An important note for those following this blog closely, [...]]]></description>
			<content:encoded><![CDATA[<p>From the project&#8217;s site:</p>
<blockquote>
<p>JSCocoa bridges Cocoa to JavascriptCore (WebKit&#8217;s JS engine). It allows you to call C code, ObjC code, use C structs, and build Javascript classes inheriting from ObjC classes.</p>
</blockquote>
<p>Basically, JSCocoa allows you to use Cocoa classes and the runtime, only using Javascript. An important note for those following this blog closely, JSCocoa does not perform the same mission or tasks as the two other popular &#8220;javascript frameworks&#8221; aiming to bring Cocoa to the web today, <a href="http://www.macfanatic.net/blog/2008/06/14/cappuccino-objective-j-and-280slidescom/" target="_top">Cappuccino</a> and <a href="http://www.macfanatic.net/blog/2008/06/15/sproutcore-feature-rich-javascript-framework/">SproutCore</a>. JSCocoa would allow a developer to write a full Cocoa application only using Javascript. I&#8217;m not really sure why anyone would do this, but it&#8217;s nice to have the capability.</p>
<p><a href="http://inexdo.com/JSCocoa" target="_blank">JSCocoa Homepage</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/10/09/jscocoa-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cappuccino 0.5.5 Released</title>
		<link>http://www.macfanatic.net/blog/2008/10/09/cappuccino-055-released/</link>
		<comments>http://www.macfanatic.net/blog/2008/10/09/cappuccino-055-released/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 13:01:01 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/10/09/cappuccino-055-released/</guid>
		<description><![CDATA[An updated version of Cappuccino is hot of the press this morning. An exciting release as this is the first one to include user contributed fixes and featrues, including some very exciting features, namely KVC and KVO support (bindings in Cocoa) and press, a tool for optimizing Cappuccino applications. To see what&#8217;s in the works [...]]]></description>
			<content:encoded><![CDATA[<p>An updated version of Cappuccino is hot of the press this morning. An exciting release as this is the first one to include user contributed fixes and featrues, including some very exciting features, namely KVC and KVO support (bindings in Cocoa) and press, a tool for optimizing Cappuccino applications. To see what&#8217;s in the works and download the latest version of Cappuccino, head over to <a href="http://github.com/280north/cappuccino/graphs/impact" target="_blank">Github</a>.</p>
<p>Version 0.5.5 includes over 60 fixes, and several key new features, including: New build tools, including:</p>
<ul>
<li>press</li>
<li>Key-Value-Observing</li>
<li>CPSplitView</li>
<li>CPWebView</li>
<li>CPDate</li>
<li>Additional Editor Support</li>
<li>Major performance gains</li>
</ul>
<p><a href="http://cappuccino.lighthouseapp.com/projects/16499-cappuccino/tickets?q=state%3Aclosed+updated%3A%22since+9%2F13%2F08%22&amp;filter=all" target="_blank">Full list of resolved bugs since 0.5.1.</a></p>
<p>Download the update directly: <a href="http://download.cappuccino.org/CappuccinoStarter-0.5.5.zip" target="_blank">Starter</a>, <a href="http://download.cappuccino.org/CappuccinoTools-0.5.5.zip" target="_blank">Tools</a>.</p>
<p>If you&#8217;re not familiar with Cappuccino, I have an <a href="http://www.macfanatic.net/blog/2008/06/14/cappuccino-objective-j-and-280slidescom/" target="_top">introductory article to look over</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/10/09/cappuccino-055-released/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>Xcode Cappuccino Plugin</title>
		<link>http://www.macfanatic.net/blog/2008/10/01/xcode-cappuccino-plugin/</link>
		<comments>http://www.macfanatic.net/blog/2008/10/01/xcode-cappuccino-plugin/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 03:11:30 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/10/01/xcode-cappuccino-plugin/</guid>
		<description><![CDATA[Great news, writing Cappuccino code is now even easier thanks to an Xcode plugin! Complete with syntax highlighting, basic code completion, project templates, and even Build &#38; Go support to easily test your application from right within Xcode. Makes the transition from iPhone or Mac programming to web even easier as you get to retain [...]]]></description>
			<content:encoded><![CDATA[<p>Great news, writing Cappuccino code is now even easier thanks to an Xcode plugin! Complete with syntax highlighting, basic code completion, project templates, and even Build &#38; Go support to easily test your application from right within Xcode. Makes the transition from iPhone or Mac programming to web even easier as you get to retain Xcode, where all Mac and iPhone developers are at home.</p>
<p>Cappuccino is a new web development platform that implements Cocoa for the web. The language, Objective-J is super similar to Objective-C and the Cocoa classes in AppKit and Foundation can be found in Cappuccino. For my first article on Cappuccino, <a href="http://www.macfanatic.net/blog/2008/06/14/cappuccino-objective-j-and-280slidescom/" target="_top">read here</a>.</p>
<p>
<img src="http://www.macfanatic.net/blog/wp-content/uploads/2008/10/xcode-step1.png" width="200" height="148" alt="xcode-step1.png" /> <img src="http://www.macfanatic.net/blog/wp-content/uploads/2008/10/xcode-step2.png" width="200" height="153" alt="xcode-step2.png" style="margin-left:33px;" /> <img src="http://www.macfanatic.net/blog/wp-content/uploads/2008/10/xcode-step3.png" width="200" height="147" alt="xcode-step3.png" style="margin-left:33px;" /></p>
<p><a href="http://cappuccino.org/files/Cappuccino_Developer_Tools.pkg" target="_blank">Download now!</a></p>
<p>Check out <a href="http://cappuccino.org/discuss/2008/10/01/using-xcode-to-develop-in-cappuccino/" target="_blank">this article from the Cappuccino blog</a> for more information</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/10/01/xcode-cappuccino-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Bluff Javascript Graphing Library</title>
		<link>http://www.macfanatic.net/blog/2008/09/23/bluff-javascript-graphing-library/</link>
		<comments>http://www.macfanatic.net/blog/2008/09/23/bluff-javascript-graphing-library/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 15:56:24 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/09/23/bluff-javascript-graphing-library/</guid>
		<description><![CDATA[For those who have ever wanted to be able to create quick and effective graphs simply from Javascript, here is the library for you. Weighing in at 8kb, with a few simple additions to your page you can have a dynamic graph. A great way to present data to users. 1 2 3 4 5 [...]]]></description>
			<content:encoded><![CDATA[<p>For those who have ever wanted to be able to create quick and effective graphs simply from Javascript, here is the library for you. Weighing in at 8kb, with a few simple additions to your page you can have a dynamic graph. A great way to present data to users.</p>
<p><img style="margin-left:150px;" src="http://www.macfanatic.net/blog/wp-content/uploads/2008/09/picture-4.jpg" alt="Picture 4.png" width="400" height="295" /></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="javascript" style="font-family:monospace;">  
  &lt;canvas id=&quot;example&quot;&gt;&lt;/canvas&gt;
  <span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
     <span style="color: #003366; font-weight: bold;">var</span> g <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Bluff.<span style="color: #660066;">Line</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'example'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">400</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     g.<span style="color: #660066;">theme_37signals</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     g.<span style="color: #660066;">title</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'My Graph'</span><span style="color: #339933;">;</span>
     g.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Apples'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     g.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Oranges'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">7</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     g.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Watermelon'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">8</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     g.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Peaches'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">9</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">7</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     g.<span style="color: #660066;">labels</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'2003'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'2004'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'2005'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
     g.<span style="color: #660066;">draw</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><a href="http://bluff.jcoglan.com/" target="_blank">Download Bluff Library</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/09/23/bluff-javascript-graphing-library/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>SproutCore Tutorial on Models</title>
		<link>http://www.macfanatic.net/blog/2008/06/17/sproutcore-tutorial-on-models/</link>
		<comments>http://www.macfanatic.net/blog/2008/06/17/sproutcore-tutorial-on-models/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 17:55:06 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/?p=1247</guid>
		<description><![CDATA[For one, the SproutCore website is now back online after being Dugg a couple days ago. And not only that, there is a very good introduction to models, records (including saving and retrieving) and a brief introduction to the local database, called the Store. If you&#8217;re interested in developing more full-featured, Desktop like apps for [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.macfanatic.net/blog/wp-content/uploads/2008/06/logo.png" alt="" title="SproutCore Logo" style="margin-left:140px;margin-top:25px" class="aligncenter size-full wp-image-1240" /></p>
<p>For one, the SproutCore website is now back online after being Dugg a couple days ago. And not only that, there is a very good introduction to models, records (including saving and retrieving) and a brief introduction to the local database, called the Store. If you&#8217;re interested in developing more full-featured, Desktop like apps for the web, you need to check out the SproutCore framework.</p>
<p><a href="http://www.sproutcore.com/2008/06/16/30-second-tutorial-on-models/" target="_blank">Models Tutorial</a></p>
<p><a href="http://www.sproutcore.com" target="_blank">SproutCore Site</a></p>
<p><a href="http://www.macfanatic.net/blog/2008/06/15/sproutcore-feature-rich-javascript-framework/" target="_blank">My Introduction to SproutCore</a></p>
<p><a href="http://280slides.com/Editor/" target="_blank">Objective-J, Cappuccino, and 280Slides.com</a></p>
<p><a href="http://www.macfanatic.net/blog/2008/06/14/cappuccino-objective-j-and-280slidescom/" target="_blank">My Introduction to Objective-J and Cappuccino</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/06/17/sproutcore-tutorial-on-models/feed/</wfw:commentRss>
		<slash:comments>1</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>Playing Leopard Intro Video from your Mac</title>
		<link>http://www.macfanatic.net/blog/2008/03/05/playing-leopard-intro-video-from-your-mac/</link>
		<comments>http://www.macfanatic.net/blog/2008/03/05/playing-leopard-intro-video-from-your-mac/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 04:42:51 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2008/03/05/playing-leopard-intro-video-from-your-mac/</guid>
		<description><![CDATA[So I have had a couple emails and some comments on this post, about finding and using the Leopard Intro video. I spent some time googling for that this evening and didn&#8217;t find anything on the subject (did find where the Panther and Tiger videos were stored though), so I thought I&#8217;d write a separate [...]]]></description>
			<content:encoded><![CDATA[<p>So I have had a couple emails and <a href="http://www.macfanatic.net/blog/2007/08/26/leopard-welcome-video/#comment-26272">some comments on this post</a>, about finding and using the Leopard Intro video.  I spent some time googling for that this evening and didn&#8217;t find anything on the subject (did find where the Panther and Tiger videos were stored though), so I thought I&#8217;d write a separate post with the location of the Leopard video.</p>
<p>You can download a quick <a href="http://www.macfanatic.net/downloads/copy_leopard_movie.zip">Automator Application</a> that will copy the two files and place them on your Desktop, or use the steps below.</p>
<p>or, in the Finder, go to:</p>
<p>/System/Library/CoreServices/</p>
<p>One of the many items in that folder is the &#8220;Setup Assistant&#8221; application.  Ctrl-click on that and choose &#8220;Show Package Contents&#8221;.</p>
<p>Now find:Contents/Resources/TransistionSection.bundle and ctrl-click on the bundle, choosing &#8220;Show Package Contents&#8221;.</p>
<p>&#8220;Contents/Resources/intro-sound.mp3&#8243; is the music that goes along with &#8220;Contents/Resources/intro.mov&#8221;</p>
<p>You can copy those files to your Desktop and run them through some software (iMovie or Quicktime Pro) and get them in one file, and you have a finished result!</p>
<p class="information">This has been verified to work with Snow Leopard, Mac OS 10.6 (<em>modified on Aug 31, 2009</em>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2008/03/05/playing-leopard-intro-video-from-your-mac/feed/</wfw:commentRss>
		<slash:comments>8</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>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>Nifty Tab Navigation</title>
		<link>http://www.macfanatic.net/blog/2007/07/27/nifty-tab-navigation/</link>
		<comments>http://www.macfanatic.net/blog/2007/07/27/nifty-tab-navigation/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 17:05:20 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Site Related]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/07/27/nifty-tab-navigation/</guid>
		<description><![CDATA[I&#8217;ve given much thought to the wonders of tabbed navigation in website design, but today I ran across a wonderful example that is brilliant in it&#8217;s simplicity. What I&#8217;m trying to accomplish is a row of tabs, but the current selected one being a different color. There are all kinds of ways to accomplish this, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve given much thought to the wonders of tabbed navigation in website design, but today I ran across a wonderful example that is brilliant in it&#8217;s simplicity.</p>
<p>What I&#8217;m trying to accomplish is a row of tabs, but the current selected one being a different color.  There are all kinds of ways to accomplish this, but here is one developer&#8217;s beautiful solution for static pages.  Just wrap each page in a different div.  Example being, homepage has &lt;div id=&#8221;home&#8221;&gt;, the Help page has &lt;div id=&#8221;help&#8221;&gt; and so forth.  On the links that make up the navigation, assign each link a class, such as &#8220;navigation-link&#8221;.  Then in the stylesheet, just add something such as</p>
<p class="code">#home  .navigation-link, #help .navigation-link { //stuff to make it stand out }</p>
<p>That works wonders.  However, in my case, I&#8217;m trying to accomplish the same thing on dynamic pages, created through a WordPress theme.  I have a dirty solution written in Javascript, but I&#8217;m going to work on writing it in PHP if at all possible so that it doesn&#8217;t have that momentary lag that the page has right now.  You can preview the work at <a href="http://www.macfanatic.net/testing/" target="_blank">http://www.macfanatic.net/testing/</a></p>
<p>Javascript Code for changing the class of a link to reflect it&#8217;s currently selected:</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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;mootools.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
window.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'domready'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> a_list <span style="color: #339933;">=</span> $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#nav li a'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #006600; font-style: italic;">// Array of nav link elements</span>
	<span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> a_list.<span style="color: #660066;">length</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">location</span>.<span style="color: #660066;">pathname</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">search</span><span style="color: #009900;">&#40;</span>a_list<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">//alert(&quot;Match found at location &quot; + i +&quot; with name &quot; + a_list[i]);</span>
			a_list<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'current'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		i<span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Also note that this uses the MooTools library, which you can download <a href="http://www.mootools.net" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/07/27/nifty-tab-navigation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Freelance Web Site Live</title>
		<link>http://www.macfanatic.net/blog/2007/05/29/first-freelance-web-site-live/</link>
		<comments>http://www.macfanatic.net/blog/2007/05/29/first-freelance-web-site-live/#comments</comments>
		<pubDate>Tue, 29 May 2007 14:46:51 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/05/29/first-freelance-web-site-live/</guid>
		<description><![CDATA[I was asked a little while back if I wanted to take on a small project and I jumped at the chance. I was given some mockups for the pages in the site and asked to turn all that into a website, in 3 weeks. 1 week early I gave the guy the files and [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked a little while back if I wanted to take on a small project and I jumped at the chance.  I was given some mockups for the pages in the site and asked to turn all that into a website, in 3 weeks.</p>
<p>1 week early I gave the guy the files and the site went live.  Overall it was an awesome experience.  Was my first time working with a client and working under a time restraint.  I was given a featureset and I had to implement all that.  In the end I was able to throw in a trick or two and get it done early, all of which pleased the guy to no end.</p>
<p>If you&#8217;re interested in taking a look at the work, you can check the site out over <a href="http://www.maclive.biz" target="_blank">here</a>.  The site is for a new podcast with multiple shows, called MacLive.  There is a teaser episode right now which you can listen to from the homepage.  Be sure to read up a little on each episode and browse around.  </p>
<p class="information">NOTE:  At the time of writing this, the site owner still hasn&#8217;t edited some text on a few pages or got the online store working yet.  He wanted the site as it was to at least have something up and will edit the other pages as the information comes available.  Just saving myself a little embarassment there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/05/29/first-freelance-web-site-live/feed/</wfw:commentRss>
		<slash:comments>0</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>Playlist Generator Code Posted</title>
		<link>http://www.macfanatic.net/blog/2007/02/05/playlist-generator-code-posted/</link>
		<comments>http://www.macfanatic.net/blog/2007/02/05/playlist-generator-code-posted/#comments</comments>
		<pubDate>Mon, 05 Feb 2007 21:18:41 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/02/05/playlist-generator-code-posted/</guid>
		<description><![CDATA[I wrote this C based program for my Data Structures Computer Science class this last fall as our last assignment. By far the most difficult program I&#8217;ve designed and coded to date and I&#8217;m very proud of it. At an overview of the program, you provide text files that have information about your music files. [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this C based program for my Data Structures Computer Science class this last fall as our last assignment.  By far the most difficult program I&#8217;ve designed and coded to date and I&#8217;m very proud of it.  At an overview of the program, you provide text files that have information about your music files.  The text file is labeled something like &#8220;Depressing.plist&#8221; and every song in that file is in the &#8220;Depressing&#8221; genre.  From there the program will match every song with the Boolean search you use.  This can get extremely complicated, but a very basic example of &#8221; 50 A Billy&#8221; would return a list of songs up to 50MB that are from an artist with the word &#8220;Billy&#8221; in it somewhere.</p>
<p>For those that aren&#8217;t comfortable using the Terminal, you won&#8217;t want to use this.  However, for anyone else a little more technically inclined, you could very well use this program for its intended purpose.  Basically, you have to provide a plain text file with a &#8220;.plist&#8221; extension ( I know this is reserved for preference files on Mac, but get over it &#8211; playlist is what it&#8217;s standing for here) that contains some basic info in a given order. </p>
<p>There is more information available in the PDF I&#8217;ve attached to this post, as it&#8217;s the same thing I had to write the program from.  This program would be great for anyone interested in learning a bit more about data organization.  The code is heavily documented showing how to use doubly-linked lists, red-black trees, hashing, and much more.  And if you&#8217;re motivated, you could always read the program description and code one yourself, them compare with my code and executable.  Sample input files are included.</p>
<p><a href="http://www.macfanatic.net/downloads/software/samplecode/playlist-generator.pdf" target="_blank">Program description and prompt ( PDF ) </a></p>
<p><a href="http://www.macfanatic.net/downloads/software/samplecode/playlist-generator.zip" target="_blank">Source Code</a> (XCode Project)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/02/05/playlist-generator-code-posted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sample Code Posted Online</title>
		<link>http://www.macfanatic.net/blog/2007/02/03/sample-code-posted-online/</link>
		<comments>http://www.macfanatic.net/blog/2007/02/03/sample-code-posted-online/#comments</comments>
		<pubDate>Sun, 04 Feb 2007 00:26:01 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Site Related]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/02/03/sample-code-posted-online/</guid>
		<description><![CDATA[I took some time this afternoon to formally post more sample code online. There will always be more discussion about the code itself when I create an individual post here on the main part of the blog, but for those just looking for the code itself, I have added it under the software section. I [...]]]></description>
			<content:encoded><![CDATA[<p>I took some time this afternoon to formally post more sample code online.  There will always be more discussion about the code itself when I create an individual post here on the main part of the blog, but for those just looking for the code itself, I have added it under the software section.  I hope to add more projects from my past Computer Sciences classes.  The data structures I dealt with were pretty intense, at least for right now in my educational career, and I&#8217;m sure there are plenty others out there who would like to see some examples of AVL trees and all that.  Anyway, a project for another day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/02/03/sample-code-posted-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Website Updated</title>
		<link>http://www.macfanatic.net/blog/2007/01/21/website-updated/</link>
		<comments>http://www.macfanatic.net/blog/2007/01/21/website-updated/#comments</comments>
		<pubDate>Sun, 21 Jan 2007 05:40:05 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Site Related]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2007/01/21/website-updated/</guid>
		<description><![CDATA[I just wanted to show off a bit more work that I put in this evening. When I first went with the redesign for the site I had grand thoughts of the big banner images changing themselves out on the page, as a showcase of my best articles. However, I rushed to get the design [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to show off a bit more work that I put in this evening.  When I first went with the redesign for the site I had grand thoughts of the big banner images changing themselves out on the page, as a showcase of my best articles.  However, I rushed to get the design live to work out a few bugs before this semester started, so now that I have worked a bit this evening, it&#8217;s alive!</p>
<p>Basically, the images in the &#8220;Hall of Fame&#8221; (that&#8217;s what the div container is called, for the stylesheet people out there) now move around a bit, so I can show a lot more articles and let the content grow more.  It&#8217;s an easy way to see what I&#8217;ve been working on and I&#8217;ll try to keep it trimmed down, so you don&#8217;t have to sit and stare at the images for a whole minute to see all of the entries.  It looks pretty cool and I&#8217;ve tested it in a few different Mac browsers, so I feel like I have all the bugs out and everything should run pretty smoothly.  If you do encounter a bug or have a suggestion, feel free to email me or talk with me on iChat.</p>
<p><a href="http://www.macfanatic.net/blog/wp-content/themes/mac_fanatic_2.0/mb_rotate_linked_images.js" target="_blank">You can grab the code, with nice comments, here</a>.  Great start for those unsure of JavaScript.  Uses arrays, element IDs, custom objects, and setInterval().</p>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2007/01/21/website-updated/feed/</wfw:commentRss>
		<slash:comments>0</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>Trials and Tribulations with PHP</title>
		<link>http://www.macfanatic.net/blog/2006/12/11/trials-and-tribulations-with-php/</link>
		<comments>http://www.macfanatic.net/blog/2006/12/11/trials-and-tribulations-with-php/#comments</comments>
		<pubDate>Tue, 12 Dec 2006 02:04:46 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Site Related]]></category>

		<guid isPermaLink="false">http://www.macfanatic.net/blog/2006/12/11/trials-and-tribulations-with-php/</guid>
		<description><![CDATA[I read through a lot of PHP over this past weekend to fine tune the site&#8217;s new look and feel. There was actually one rather nasty bug in the last version that I&#8217;ve missed for the past 6 months or so. So, to elaborate on that bug and the relatively easy solution, here is some [...]]]></description>
			<content:encoded><![CDATA[<p>I read through a lot of PHP over this past weekend to fine tune the site&#8217;s new look and feel.  There was actually one rather nasty bug in the last version that I&#8217;ve missed for the past 6 months or so.  So, to elaborate on that bug and the relatively easy solution, here is some code below.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;span class=&quot;date&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'F jS, Y'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/span&gt; &amp;bull; &lt;span class=&quot;postmetadata&quot;&gt;Tags: <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_category<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;strong&gt;|&lt;/strong&gt; '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;); ?&gt;&lt;/span&gt;
&nbsp;
&lt;div id=&quot;</span>entry<span style="color: #0000ff;">&quot;&gt;
&nbsp;
	&lt;?php the_content('Read the rest of this entry;'); ?&gt;
&nbsp;
	&lt;!– Checks to see if this is a post page. If it is, then we don't want to display the comments link. If not, we want to display it (main page basically) –&gt;
	&lt;?php if (!is_single() &amp;&amp; !is_page()) : ?&gt;
		&lt;p&gt;&lt;div id = “main-comments&quot;</span><span style="color: #339933;">&gt;</span>There are <span style="color: #000000; font-weight: bold;">&lt;?php</span> comments_popup_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No Comments'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'1 Comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'% Comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> for 'lt;?php the_title(); ?&gt;'&lt;/div&gt;&lt;/p&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;/div&gt;</pre></td></tr></table></div>

<p>The problem I was trying to fix was simple.  When you are on the main page of the site with all the posts, you want to be able to see the area under the post that displays information like &#8220;There are (some #) comments for (post name)&#8221;.  You don&#8217;t need to see that when you are on the actual post&#8217;s page to read the full post and look at comments.  You also don&#8217;t need to see a date and tag info for pages in WordPress, such as the new About and Downloads pages.  Just of note, I have left Rapidweaver for this site.  It&#8217;s on a sad note since Rapidweaver is what spawned this site almost a year ago this week.  It&#8217;s been a great year and I&#8217;ll more about that later, but I&#8217;m no longer using Rapidweaver on the site.</p>
<p>To put it simply, the issue I was having was with the PHP if() statement, by trying to have the HTML code on the page only if it met that condition.  The solution my my problem came with the realization of a colon operator in PHP that allowed me to write the above code.  Just out there for anyone else that might be having issues as well.</p>
<div class="code">
// Anything between this and the endif statement will only execute if the viewer isn&#8217;t viewing a page (ie, viewing the main blog page)<br />
&lt;?php if ( !is_page() ) : ?&gt;<br />
&lt;? endif; ?&gt;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.macfanatic.net/blog/2006/12/11/trials-and-tribulations-with-php/feed/</wfw:commentRss>
		<slash:comments>0</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>

