<?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>roobasoft blog &#187; Code</title>
	<atom:link href="http://roobasoft.com/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://roobasoft.com/blog</link>
	<description></description>
	<lastBuildDate>Sun, 15 Apr 2012 17:02: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>RooAlertView</title>
		<link>http://roobasoft.com/blog/2011/11/18/rooalertview/</link>
		<comments>http://roobasoft.com/blog/2011/11/18/rooalertview/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 14:31:20 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/?p=234</guid>
		<description><![CDATA[On the twitters, friend Justin Driscoll mentioned: iOS needs a block-based UIAlertView. So many currently-delegate based interfaces would be better served by block callbacks. I&#8217;ve wanted the same. I&#8217;ve also wanted to contribute more open source code. With some time on my hands, I threw together RooAlertView. As I mention in the README, I&#8217;m not [...]]]></description>
			<content:encoded><![CDATA[<p>On the twitters, friend <a href="http://twitter.com/jdriscoll">Justin Driscoll</a> <a href="https://twitter.com/#!/jdriscoll/status/137513067033526272">mentioned</a>:</p>

<blockquote>
  <p>iOS needs a block-based UIAlertView. So many currently-delegate based interfaces would be better served by block callbacks.</p>
</blockquote>

<p>I&#8217;ve wanted the same. I&#8217;ve also wanted to contribute more open source code. With some time on my hands, I threw together <a href="https://github.com/bricooke/RooAlertView">RooAlertView</a>.</p>

<p>As I mention in the README, I&#8217;m not terribly happy with it. I like the public interface, a single class method. But am sad to report that the static analyzer doesn&#8217;t like the implementation. The static method alloc, init&#8217;s a RooAlertView and then relies on the UIAlertViewDelegate&#8217;s callback to be called and then releases itself. I&#8217;m fairly confident it works and all, but am hopeful someone will provide a better solution that the analyzer likes and that&#8217;s probably cleaner.</p>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2011/11/18/rooalertview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Uncrustified</title>
		<link>http://roobasoft.com/blog/2010/08/05/uncrustified/</link>
		<comments>http://roobasoft.com/blog/2010/08/05/uncrustified/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 13:34:58 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/?p=231</guid>
		<description><![CDATA[While looking for how to setup user scripts in Xcode 4 I stumbled into Tony Arnold&#8217;s Xcode-4-Uncrustify-Automator-Services on github. Creating a service with Automator answered my original, but the real find was uncrustify. From the uncrustify website: The goals of this project are simple: Create a highly configurable, easily modifiable source code beautifier. Since Tony [...]]]></description>
			<content:encoded><![CDATA[<p>While looking for how to setup user scripts in Xcode 4 I stumbled into <a href="http://tonyarnold.com">Tony Arnold&#8217;s</a> <a href="http://github.com/tonyarnold/Xcode-4-Uncrustify-Automator-Services">Xcode-4-Uncrustify-Automator-Services</a> on github. Creating a service with Automator answered my original, but the real find was <a href="http://uncrustify.sourceforge.net/">uncrustify</a>.</p>

<p>From the uncrustify website:</p>

<blockquote>
  <p>The goals of this project are simple: Create a highly configurable, easily modifiable source code beautifier.</p>
</blockquote>

<p>Since Tony had provided nice Automator actions, I figured I&#8217;d take it for a spin. After a quick</p>

<pre><code>brew install uncrustify
</code></pre>

<p>and a few minutes messing with <a href="http://gist.github.com/261662/">Tony&#8217;s sample .uncrustify.cfg</a> making <a href="http://gist.github.com/509705">my own</a>, I was impressed.</p>

<p>While in Xcode 4 I used Tony&#8217;s Automator service to uncrustify the selected text (I select whole files at a time). However, I had to give up on Xcode 4 due to stability issues so found myself back in Xcode 3.2.x. While in Xcode 3 I decided to create a User Script for uncrustify, thinking it would be much faster to execute. So now I have a shell script execute uncrustify on the selection and replace the selection with the uncrustified result (stealing the uncrustify line from Tony&#8217;s Automator service). I also have this bound to cmd+option+ctrl+u.</p>

<pre><code>#!/bin/sh
/usr/local/bin/uncrustify -l OC -q
</code></pre>

<p>Here&#8217;s the User Script setup:</p>

<p><img src="http://rawk.it/s/Edit_User_Scripts-20100805-071604.png" alt="user script setup in Xcode 3.2.3" /></p>

<p><small>Liar! Note that it says I&#8217;m using &#8216;g&#8217; as the shortcut instead of &#8216;u&#8217; like I said. I&#8217;m pushing the &#8216;u&#8217; key but it&#8217;s bound to &#8216;g&#8217; in the Dvorak keyboard layout.</small></p>

<p>I&#8217;m not sure if I&#8217;m early or late to the uncrustify party, but I&#8217;m happy to be here.</p>

<p>Oh, and if someone does know how to setup User Scripts in Xcode 4, do tell!</p>

<p>Wait, one more thing! I&#8217;m working on a project where my 6 lines of whitespace after each function body wasn&#8217;t appreciated (understandable, it&#8217;s not for everyone <img src='http://roobasoft.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ). <a href="http://rooswitch.com">rooSwitch</a> to the rescue! I already have profiles for slight differences in Xcode prefs, so I dropped my .uncrustify.cfg on each profile and am now switching that file with the slight difference for this project. Success.</p>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2010/08/05/uncrustified/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force Google&#8217;s ClientLogin to Require a CAPTCHA</title>
		<link>http://roobasoft.com/blog/2008/09/20/force-googles-clientlogin-to-require-a-captcha/</link>
		<comments>http://roobasoft.com/blog/2008/09/20/force-googles-clientlogin-to-require-a-captcha/#comments</comments>
		<pubDate>Sun, 21 Sep 2008 02:02:06 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/2008/09/20/force-googles-clientlogin-to-require-a-captcha/</guid>
		<description><![CDATA[I&#8217;ve been working with Google&#8217;s Account Authentication API lately. Specifically working with ClientLogin. One problem I ran into is that ClientLogin says that it may return a response of 403 with an error of &#8220;CaptchaRequired&#8221;. When that happens you&#8217;re supposed to display the provided CAPTCHA image to the user and have them give the answer. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with <a href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html">Google&#8217;s Account Authentication API</a> lately. Specifically working with ClientLogin. One problem I ran into is that ClientLogin says that it may return a response of 403 with an error of &#8220;CaptchaRequired&#8221;. When that happens you&#8217;re supposed to display the provided CAPTCHA image to the user and have them give the answer. This is all fine and good, but Google doesn&#8217;t provide a way for you to force this CAPTCHA requirement.  To work around this I wrote a quick Ruby script so I can say:</p>

<p><code>
  GoogleAuth.setup_captcha("some@email.com")
</code></p>

<p>After that runs, the next time I try ClientLogin with that email address it&#8217;s almost guaranteed that the CAPTCHA requirement will happen.</p>

<p>The script is available at <a href="http://gist.github.com/11820">http://gist.github.com/11820</a></p>

<p>As you can see, the script just hammers away trying to log into the given account until Google returns with the CaptchaRequired response.</p>

<p>No this isn&#8217;t nice or pretty. Ideally Google would let us pass a parameter that would force the CAPTCHA requirement to happen. Until then, this works.</p>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2008/09/20/force-googles-clientlogin-to-require-a-captcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Growl When Done</title>
		<link>http://roobasoft.com/blog/2008/04/03/growl-when-done/</link>
		<comments>http://roobasoft.com/blog/2008/04/03/growl-when-done/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 01:45:17 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/2008/04/03/growl-when-done/</guid>
		<description><![CDATA[I was waiting for a MySQL migration to finish when I said to a friend: &#8220;mysql should have growl support to tell me when a lengthy operation is done&#8221;. 10 seconds later that became: &#8220;Even better, there should be a command like &#8216;time&#8217; that would growl when whatever command you give it is done&#8221;. 3 [...]]]></description>
			<content:encoded><![CDATA[<p>I was waiting for a MySQL migration to finish when I said to a friend: &#8220;mysql should have growl support to tell me when a lengthy operation is done&#8221;. 10 seconds later that became: &#8220;Even better, there should be a command like &#8216;time&#8217; that would growl when whatever command you give it is done&#8221;. 3 minutes later and I finished the bash version of Growl When Done:</p>

<p><code>
gwd()<br />
{<br />
&nbsp;&nbsp;$*<br />
&nbsp;&nbsp;growlnotify "${1} is done" -m '...'<br />
}<br />
</code></p>

<p>Drop that in your .bashrc or .bash_profile and you can now do things like:</p>

<p><code>
gwd sleep 1<br />
gwd some time consuming command
</code></p>

<p><strong>Assumptions</strong>:
 * You have growl and the command line growlnotify installed
 * You use bash</p>

<p><strong>Update</strong>: 
The friend I was talking with didn&#8217;t have growlnotify installed. His google search for &#8216;growlnotify install&#8217; turned up this, much more complete solution: <a href="http://www.simplicidade.org/notes/archives/2007/08/tip_use_growlno.html">http://www.simplicidade.org/notes/archives/2007/08/tip&#95;use&#95;growlno.html</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2008/04/03/growl-when-done/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m Talking RubyCocoa Tonight</title>
		<link>http://roobasoft.com/blog/2007/01/31/im-talking-rubycocoa-tonight/</link>
		<comments>http://roobasoft.com/blog/2007/01/31/im-talking-rubycocoa-tonight/#comments</comments>
		<pubDate>Wed, 31 Jan 2007 18:00:48 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/2007/01/31/im-talking-rubycocoa-tonight/</guid>
		<description><![CDATA[I&#8217;m going to be showing some slides (and talking over the slides) and doing a demo of RubyCocoa tonight for the Boise ruby brigade. I&#8217;ll post the code and slides tomorrow for anyone that might care. Hopefully someone learns something (minimally, I think I&#8217;ll get a lot out of it)]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://roobasoft.com/blog/wp-content/uploads/rclogo.jpg" height="64" width="152" border="0" align="right" hspace="4" vspace="4" alt="Rclogo" />
<br />I&#8217;m going to be showing some slides (and talking over the slides) and doing a demo of <a href="http://rubycocoa.com">RubyCocoa</a> tonight for the Boise <a href="http://boiserb.com">ruby brigade</a>. I&#8217;ll post the code and slides tomorrow for anyone that might care. Hopefully someone learns something <img src='http://roobasoft.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (minimally, I think I&#8217;ll get a lot out of it)
</p>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2007/01/31/im-talking-rubycocoa-tonight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing TraineoWeight.wdgt</title>
		<link>http://roobasoft.com/blog/2007/01/20/introducing-traineoweightwdgt/</link>
		<comments>http://roobasoft.com/blog/2007/01/20/introducing-traineoweightwdgt/#comments</comments>
		<pubDate>Sat, 20 Jan 2007 14:27:02 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Dashboard]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[releases]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/2007/01/20/introducing-traineoweightwdgt/</guid>
		<description><![CDATA[Update: The traineo guys provided an API and I updated the widget. See: TraineoWeight.wdgt Updated Like most Americans I&#8217;d prefer to be less fat. To help me with that goal I&#8217;ve been logging my weight on traineo.com. They offer plenty more than just weight tracking, but I haven&#8217;t gotten into all that quite yet. Anyway, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:right;">
<img src="http://roobasoft.com/blog/wp-content/uploads/traineo59.png" height="252" width="152" border="0" align="right" hspace="4" vspace="4" alt="Yes, I really want to lose that much" title="Yes, I really want to lose that much" /><img src="http://roobasoft.com/blog/wp-content/uploads/traineodone.png" height="252" width="152" border="0" align="right" hspace="4" vspace="4" alt="Traineodone" />
</p>

<p>
<strong>Update: </strong>The traineo guys provided an API and I updated the widget. See: <a href="http://roobasoft.com/blog/2007/01/24/traineoweightwdgt-updated/" title="roobaLog » Blog Archive » TraineoWeight.wdgt Updated">TraineoWeight.wdgt Updated</a>
</p>

<p>
Like most Americans I&#8217;d prefer to be less fat. To help me with that goal I&#8217;ve been logging my weight on <a href="http://traineo.com">traineo.com</a>. They offer plenty more than just weight tracking, but I haven&#8217;t gotten into all that quite yet. Anyway, it seemed silly to log into a web page just to enter my weight each day (who has the time for that! <img src='http://roobasoft.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  &lt;/lazy&gt;). So I pinged the traineo folks and got this in reply:
</p>

<blockquote>
I&#8217;m afraid that at the moment we don&#8217;t have an open API, although we are planning to release one in the not-too-distant future.
<br />
<br />&lt;snip&gt;
<br />
<br />If you want to input your weight remotely, this is possible, but not something we actively advertise, as it&#8217;s currently not really ready for public consumption.
<br />
<br />If you were to visit http://they.made.it.sound/like/i/shouldnt/share while logged in (i.e. you have a cookie saved in your browser (they don&#8217;t go stale for a long time)), your weight would be submitted.
</blockquote>

<p>
To which I said (to myself): &#8220;C Is for cookie, that&#8217;s good enough for me!&#8221;.
</p>

<p>
When I found myself awake at 3am[1]. I knew just what to do:
</p>

<p>
1) Fire up <a href="http://developer.apple.com/tools/dashcode/">Dashcode</a>
<br />2) Author a widget based on a template Apple provided[2] using 1997 methods of screen scraping[3].
<br />3) Publish widget with minimal testing
<br />4) Hope traineo doesn&#8217;t change their response HTML
</p>

<p>
This took ~3 hours of my time[4] and surely has bugs and will surely break when traineo changes their response. I provide this &#8220;as is&#8221;. With that:
</p>

<p>
Enjoy! <a href="http://roobasoft.com/widgets/TraineoWeight.wdgt.zip">TraineoWeight.wdgt.zip</a>  Make sure you log into your traineo account with Safari first.
</p>

<p>
[1] our 3 year old likes to wake me up and make me tuck her back in (it&#8217;s not that bad really &#8211; I&#8217;m sure I&#8217;ll miss it when it stops).
<br />[2] I can&#8217;t make pretty things. But I can copy pretty things!
<br />[3] .substring() &#8211; I fought the DOM parser for too long and finally reverted to .substring(). Yes, this is a hack and this widget *will* break someday&#8230;possibly soon.
<br />[4] I would have never tried this without Dashcode. It&#8217;s pretty slick. Two thumbs up.
<br />[5] Wait&#8230;there wasn&#8217;t a [5]. Well, if you want access to the Dashcode project let me know and I&#8217;ll put up an svn repo. Feel free to take the widget and do with it what you will.
</p>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2007/01/20/introducing-traineoweightwdgt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Time Out Your Beta App X Days From When it was Built</title>
		<link>http://roobasoft.com/blog/2006/06/09/time-out-your-beta-app-x-days-from-when-it-was-built/</link>
		<comments>http://roobasoft.com/blog/2006/06/09/time-out-your-beta-app-x-days-from-when-it-was-built/#comments</comments>
		<pubDate>Fri, 09 Jun 2006 17:52:17 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/2006/06/09/time-out-your-beta-app-x-days-from-when-it-was-built/</guid>
		<description><![CDATA[I&#8217;m working on an application that will be going into a private beta pretty soon, followed by a public beta. One of the things I wanted to do was make sure the application stopped working after 30 days from when it was built. This is to make sure the beta testers are running the latest [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on an application that will be going into a private beta pretty soon, followed by a public beta. One of the things I wanted to do was make sure the application stopped working after 30 days from when it was built. This is to make sure the beta testers are running the latest and greatest version.</p>

<p>So to avoid having to manually update the date every time I release a new beta, I used gcc&#8217;s &#95;&#95;DATE&#95;&#95; to come up with the following code:</p>

<p><pre class="code"><br />
    NSDate <em>expirationDate = 
        [[NSDate dateWithNaturalLanguageString:
            [NSString stringWithCString:<strong>DATE</strong>]] 
            addTimeInterval:(60</em>60<em>24</em>30/<em>30 days</em>/)];</pre></p>

<pre><code>if( [expirationDate earlierDate:[NSDate date]] 
     == expirationDate )
{
    int result = NSRunAlertPanel(@"Beta Expired", 
                 @"This beta has expired, please visit "
                 "http://roobasoft.com/rooAppNumber2 to grab"
                 "the latest version.", 
                 @"Take Me There", @"Exit", nil);

    if( result == NSAlertDefaultReturn )
    {
        [[NSWorkspace sharedWorkspace] openURL:
                  [NSURL URLWithString:
                   @"http://roobasoft.com/rooAppNumber2"]];
    }
    [[NSApplication sharedApplication] terminate:self];
}
</code></pre>

<p></p>

<p>Make sure the file that contains this code is always compiled before you ship your beta. Otherwise the <strong>DATE</strong> referenced will be whenever the file containing it was compiled. This works for me because I keep a separate â€œproductionâ€ sandbox where a clean build is run before handing anything out.</p>

<p>Want to get fancy? Use <a href="http://toxicsoftware.com/blog/are_you_feeling_a_little_hyper_alert">Hyper Alert</a> to make the URL clickable or to pretty it up a bit. You could probably have it pull release notes for the current release from a pre-defined location (that&#8217;s an assumption &#8211; I haven&#8217; tried this).</p>

<p><a href="http://www.cocoadev.com/index.pl?SetADateForAnAppToExpire">SetADateForAnAppToExpire</a> on CocoaDev wiki has some more information. Enjoy!.</p>

<p>p.s. If for some reason you&#8217;re interested in participating in a private beta of â€œrooAppNumber2â€ without knowing anything about it, send a note to <a href="mailto:rooAppNumber2@roobasoft.com">rooAppNumber2@roobasoft.com</a>  I&#8217;ll make sure you get notified on how to participate when it&#8217;s ready. rooAppNumber2 will require OS X 10.4.</p>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2006/06/09/time-out-your-beta-app-x-days-from-when-it-was-built/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mistakes I Made Using Bindings Without Core Data</title>
		<link>http://roobasoft.com/blog/2006/06/07/mistakes-i-made-using-bindings-without-core-data-2/</link>
		<comments>http://roobasoft.com/blog/2006/06/07/mistakes-i-made-using-bindings-without-core-data-2/#comments</comments>
		<pubDate>Wed, 07 Jun 2006 13:24:33 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/2006/06/07/mistakes-i-made-using-bindings-without-core-data-2/</guid>
		<description><![CDATA[Key-Value Coding is part of the magic behind Cocoa&#8217;s bindings. Up until yesterday I had only been binding to an ObjectController or to an ArrayController backed by Core Data. This is very powerful, but bindings pre-date Core Data so clearly not a necessity. So yesterday I went to bind an NSProgressIndicator&#8217;s &#8216;isIndeteriminate&#8217; to a BOOL. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/BasicPrinciples.html">Key-Value Coding</a> is part of the magic behind Cocoa&#8217;s <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/CocoaBindings.html">bindings</a>. Up until yesterday I had only been binding to an ObjectController or to an ArrayController backed by Core Data. This is very powerful, but bindings pre-date Core Data so clearly not a necessity. So yesterday I went to bind an NSProgressIndicator&#8217;s &#8216;isIndeteriminate&#8217; to a BOOL. Two gotchas that I ran into that I can see myself running into again:</p>

<p>1) <b>update 6.7.06</b>: there is no #1 &#8211; I just had this blatantly wrong &#8211; see comments. Thanks Jean-Francois.</p>

<p>&lt;</p>

<p>p>
<strike>Binding to a BOOL requires the result to be returned in an NSNumber. My isIndeterminate method, although backed by a simple BOOL, needed to be
<pre class="code">- (NSNumber <em>) isIndeterminate
{
return [NSNumber numberWithBool:isIndeterminate];
}</em></pre></strike>
2) Bindings require you to notify them when you change the value (see, it&#8217;s not *all magic). So setIsIndeterminate looks like this:
<pre class="code">- (void)setIsIndeteriminate:(NSNumber *)flag
{
[self willChangeValueForKey:@â€œisIndeteriminateâ€];
isIndeteriminate = [flag boolValue];
[self didChangeValueForKey:@â€œisIndeteriminateâ€];
}</pre>
Without this, changing the isIndeterminate member variable would have no effect.</p>

<p>Some other goodies:</p>

<ul>
    <li><a href="http://www.kevincallahan.org/software/accessorizer.html">Accessorizer</a> can create your accessor methods for you. This is a great tool that greatly speeds up a tedious task.</li>
</ul>

<ul>
    <li><a onclick="window.open('http://roobasoft.com/blog/wp-content/uploads/coredata_menu.png','popup','width=427,height=74,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0');return false" href="http://roobasoft.com/blog/wp-content/uploads/coredata_menu.png"><img width="288" vspace="4" hspace="4" height="50" border="0" align="right" alt="Coredata Menu" src="http://roobasoft.com/blog/wp-content/uploads/coredata_menu-tm.jpg" /></a>Core Data can generate similar code for you. Go to your data model and right click on an entities attribute. You should see a â€œCopy Method Declarations to Clipboardâ€ and a â€œCopy Method Implementations to Clipboardâ€. Core Data doesn&#8217;t need you to generate these. If you use the setValue:foo forKey:@â€œbarâ€ syntax the correct things happen. However, it&#8217;s often nice to just say [obj setBar:foo];</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2006/06/07/mistakes-i-made-using-bindings-without-core-data-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Getting Default Application Icon as NSImage</title>
		<link>http://roobasoft.com/blog/2006/05/31/getting-default-application-icon-as-nsimage/</link>
		<comments>http://roobasoft.com/blog/2006/05/31/getting-default-application-icon-as-nsimage/#comments</comments>
		<pubDate>Wed, 31 May 2006 05:15:43 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Commentary]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/2006/05/31/getting-default-application-icon-as-nsimage/</guid>
		<description><![CDATA[To get the icon that represents an application with no custom icon (default application icon) just call: [NSImage imageNamed:@â€œNSDefaultApplicationIconâ€];]]></description>
			<content:encoded><![CDATA[<p>To get the icon that represents an application with no custom icon (default application icon) just call:
<pre class="code">[NSImage imageNamed:@â€œNSDefaultApplicationIconâ€];
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2006/05/31/getting-default-application-icon-as-nsimage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You Can Pass &#8216;NO&#8217; as a NSNumber, But You Probably Don&#8217;t Want To</title>
		<link>http://roobasoft.com/blog/2006/05/30/you-can-pass-no-as-a-nsnumber-but-you-probably-dont-want-to/</link>
		<comments>http://roobasoft.com/blog/2006/05/30/you-can-pass-no-as-a-nsnumber-but-you-probably-dont-want-to/#comments</comments>
		<pubDate>Tue, 30 May 2006 07:22:50 +0000</pubDate>
		<dc:creator>BrianC</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://roobasoft.com/blog/2006/05/30/you-can-pass-no-as-a-nsnumber-but-you-probably-dont-want-to/</guid>
		<description><![CDATA[When using Core Data, Boolean values as an attribute are represented using NSNumber. That&#8217;s all fine and good, but it requires you to use [NSNumber numberWithBool:YES&#124;NO] when you set the value. NO is defined as: define NO (BOOL)0 we have an issue. 0 is also &#8216;nil&#8217;. Just below the definition of NO we see nil: [...]]]></description>
			<content:encoded><![CDATA[<p>When using Core Data, Boolean values as an attribute are represented using NSNumber. That&#8217;s all fine and good, but it requires you to use [NSNumber numberWithBool:YES|NO] when you set the value.</p>

<p>NO is defined as:</p>

<p><pre class="code"></pre></p>

<h1>define NO              (BOOL)0</h1>

<p></p>

<p>we have an issue. 0 is also &#8216;nil&#8217;. Just below the definition of NO we see nil:</p>

<p><pre class="code"></pre></p>

<h1>define nil 0       /* id of Nil instance */</h1>

<p></p>

<p>Since &#8216;nil&#8217; has to be a valid NSNumber *, you are allowed to pass NO as a NSNumber * parameter. If object &#8216;foo&#8217; has a method &#8216;setBarOn&#8217; with a declaration of 
<pre class="code">
- (void) setBarOn:(NSNumber *)aBooleanAsANumber;
- (NSNumber *) barOn;
</pre></p>

<p>You need to make sure you never call that method with NO, as in:</p>

<p><pre class="code">
[foo setBarOn:NO]; 
</pre></p>

<p>If you were to try to read the boolValue by hand you&#8217;d be <em>OK</em>. Calling &#8216;boolValue&#8217; on a nil object seems to return 0, which is NO, so you wouldn&#8217;t notice the problem. The problem comes in when you use predicates.</p>

<p>I had a predicate that looked like:</p>

<p><pre>
â€œisBarOn == 0â€
</pre></p>

<p>If you setBarOn:NO instead of setBarOn:[NSNumber numberWithBool:NO] the instance in question will not be returned by this predicate. Ouch. Fortunately if you were to look at the attribute that had been set to :NO you&#8217;ll see it reported as (null), which is a good hint your Boolean got set wrong.</p>

<p>I&#8217;m not sure how common this is or not, but it seemed worthy of pointing out. Hopefully it made some sense to someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://roobasoft.com/blog/2006/05/30/you-can-pass-no-as-a-nsnumber-but-you-probably-dont-want-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

