<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Kevin Ballard is a Mac/iPhone developer</description><title>blog.eridi.us</title><generator>Tumblr (3.0; @eridius)</generator><link>http://blog.eridi.us/</link><item><title>Philosophy for coding tricks</title><description>&lt;p&gt;A lot of what we do in programming is defining a subset of the language that
we’re comfortable working with. This is especially notable with C++, but is seen
elsewhere. In our subset of the language we adopt a lot of little tricks and
rules that reduce the mental burden of writing code. This way we can write code
quickly without having to think about every single line. If your mental rule of
thumb is good enough, then you can trust it to do the right thing. However if
you come up with rules that contain edge cases that the code they’re replacing
doesn’t have, then you’re doing yourself a disservice. For example, for object
initialization if your mental rule is “nobody ever returns another object from
&lt;code&gt;[super init]&lt;/code&gt; besides self”, you might come up with the following boilerplate:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if ([super init] == nil) return nil;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You may think this is fine because if you’re subclassing something that can
return a different object, obviously you’d actually write the “correct” code,
right? The thing is, you’re just setting yourself up to fail. The mental trick
you’ve employed means that you &lt;em&gt;aren’t&lt;/em&gt; thinking about it when you’re writing
it, and you’re highly likely to forget about the edge case until you hit the bug
in the wild.&lt;/p&gt;

&lt;p&gt;For this reason, mental tricks that you employ need to be constructed to be safe
and always handle the edge cases, even if the edge cases don’t exist 99% of the
time you employ the code. For example, the clasically recommended way to write
an initializer in obj-c looks like&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if ((self = [super init])) {
    // write code here
}
return self;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;By always following this pattern, even if you know &lt;code&gt;[super init]&lt;/code&gt; will always
return &lt;code&gt;self&lt;/code&gt;, you’ll be safe in the rare occasion that it actually doesn’t.&lt;/p&gt;

&lt;p&gt;Another example of a mental trick I like to employ is the strict usage of ivars
in &lt;code&gt;-init&lt;/code&gt;/&lt;code&gt;-dealloc&lt;/code&gt;. In most cases, calling a property setter in &lt;code&gt;-dealloc&lt;/code&gt;
isn’t going to cause a problem, but in rare cases it will introduce bugs in your
application, either due to overridden setters or KVO. By restricting myself to
ivars only in &lt;code&gt;-init&lt;/code&gt;/&lt;code&gt;-dealloc&lt;/code&gt; I’m protected against the edge cases no matter
what class I’m currently working in. It frees me from the need to think about
every property setter to make sure it’s safe to call in these environments. It
also encourages cleaner code. If a property setter has a side-effect that I need
to occur in &lt;code&gt;-dealloc&lt;/code&gt;, then I can move that to a separate function that’s
explicitly documented as being safe to call in &lt;code&gt;-dealloc&lt;/code&gt;, and then I can call
that inside of &lt;code&gt;-dealloc&lt;/code&gt; instead of calling the property setter. This makes the
side-effect immediately obvious in &lt;code&gt;-dealloc&lt;/code&gt; and saves me from introducing bugs
later if I modify the side-effecting function (since, as I said before, I’ve
clearly documented that this gets called from &lt;code&gt;-dealloc&lt;/code&gt;).&lt;/p&gt;</description><link>http://blog.eridi.us/post/16791505841</link><guid>http://blog.eridi.us/post/16791505841</guid><pubDate>Mon, 30 Jan 2012 17:10:00 -0800</pubDate></item><item><title>TinEye Safari Extensions</title><description>&lt;a href="http://kevin.sb.org/2010/06/12/tineye-safari-extensions/"&gt;TinEye Safari Extensions&lt;/a&gt;: &lt;p&gt;&lt;a href="http://www.tineye.com"&gt;TinEye&lt;/a&gt; is a cool reverse image search engine. It lets you take an image and search for it on the web, even finding uncropped, expanded, or unwatermarked versions of the image. Sadly, while TinEye…&lt;/p&gt;</description><link>http://blog.eridi.us/post/693578449</link><guid>http://blog.eridi.us/post/693578449</guid><pubDate>Sun, 13 Jun 2010 04:46:04 -0700</pubDate></item><item><title>CleanGoogle Safari extension</title><description>&lt;a href="http://kevin.sb.org/2010/06/10/cleangoogle-safari-extension/"&gt;CleanGoogle Safari extension&lt;/a&gt;: &lt;p&gt;If you’re like anybody else that I know, you were rather shocked and appalled to see Google follow the likes of &lt;a href="http://bing.com"&gt;Bing&lt;/a&gt; and add background images to their home page. If you’re also like anybody else…&lt;/p&gt;</description><link>http://blog.eridi.us/post/683502365</link><guid>http://blog.eridi.us/post/683502365</guid><pubDate>Thu, 10 Jun 2010 05:31:08 -0700</pubDate></item><item><title>1Password extension loading in Snow Leopard</title><description>&lt;a href="http://kevin.sb.org/2009/09/02/1password-extension-loading-in-snow-leopard/"&gt;1Password extension loading in Snow Leopard&lt;/a&gt;: &lt;p&gt;One of the big changes in Snow Leopard is the move to 64-bit applications system-wide. This includes Safari. Unfortunately, this change breaks all of the Safari plugins out there, including mine….&lt;/p&gt;</description><link>http://blog.eridi.us/post/178263302</link><guid>http://blog.eridi.us/post/178263302</guid><pubDate>Wed, 02 Sep 2009 15:13:49 -0700</pubDate></item><item><title>Zynga is Hiring</title><description>&lt;a href="http://kevin.sb.org/2009/05/18/zynga-is-hiring/"&gt;Zynga is Hiring&lt;/a&gt;: &lt;p&gt;If you’ve been following me, you’re aware that I’ve been working at &lt;a href="http://www.zynga.com"&gt;Zynga&lt;/a&gt; for the past two weeks. Well, they’re still hiring more people (and not just iPhone developers). You can see the available…&lt;/p&gt;</description><link>http://blog.eridi.us/post/109662382</link><guid>http://blog.eridi.us/post/109662382</guid><pubDate>Mon, 18 May 2009 14:48:38 -0700</pubDate></item><item><title>ExecTweets on the App Store</title><description>&lt;a href="http://kevin.sb.org/2009/05/18/exectweets-on-the-app-store/"&gt;ExecTweets on the App Store&lt;/a&gt;: &lt;p&gt;My last iPhone contract app, &lt;a href="http://exectweets.com"&gt;ExecTweets&lt;/a&gt; for iPhone, is now on the &lt;a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=314677692&amp;mt=8"&gt;App Store&lt;/a&gt;. This is the project that drove the creation of &lt;a href="http://github.com/kballard/feedparser"&gt;FeedParser&lt;/a&gt; (an open source Obj-C RSS parser). Anyway, it’s free, and…&lt;/p&gt;</description><link>http://blog.eridi.us/post/109662385</link><guid>http://blog.eridi.us/post/109662385</guid><pubDate>Mon, 18 May 2009 14:48:38 -0700</pubDate></item><item><title>Major FontLabel update</title><description>&lt;a href="http://kevin.sb.org/2009/05/18/major-fontlabel-update/"&gt;Major FontLabel update&lt;/a&gt;: &lt;p&gt;Last week I pushed out a major rewrite of &lt;a href="http://github.com/zynga/FontLabel"&gt;FontLabel&lt;/a&gt;. This new version includes a category modeled after UIStringDrawing that enables you to draw text in custom fonts in your own &lt;code&gt;drawRect:&lt;/code&gt;…&lt;/p&gt;</description><link>http://blog.eridi.us/post/109662384</link><guid>http://blog.eridi.us/post/109662384</guid><pubDate>Mon, 18 May 2009 14:48:38 -0700</pubDate></item><item><title>MyLifeIsAverage - Life Is Normal Today</title><description>&lt;a href="http://www.mylifeisaverage.com/"&gt;MyLifeIsAverage - Life Is Normal Today&lt;/a&gt;</description><link>http://blog.eridi.us/post/107074604</link><guid>http://blog.eridi.us/post/107074604</guid><pubDate>Tue, 12 May 2009 22:27:23 -0700</pubDate></item><item><title>Starting a new job</title><description>&lt;a href="http://kevin.sb.org/2009/04/28/starting-a-new-job/"&gt;Starting a new job&lt;/a&gt;: &lt;p&gt;This coming monday, I am going to stop being an iPhone contractor and start being a full-time employee of &lt;a href="http://www.zynga.com"&gt;Zynga&lt;/a&gt;. While there, I will be working on developing iPhone games.&lt;/p&gt;</description><link>http://blog.eridi.us/post/101262814</link><guid>http://blog.eridi.us/post/101262814</guid><pubDate>Tue, 28 Apr 2009 18:01:57 -0700</pubDate></item><item><title>DNS-SD Browser is on the AppStore</title><description>&lt;a href="http://kevin.sb.org/2009/04/10/dns-sd-browser-is-on-the-appstore/"&gt;DNS-SD Browser is on the AppStore&lt;/a&gt;: &lt;p&gt;&lt;a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=305441017&amp;mt=8"&gt;DNS-SD Browser&lt;/a&gt; has finally been released on the iTunes AppStore.&lt;/p&gt; &lt;p&gt;DNS-SD Browser is the iPhone version of my popular desktop &lt;a href="http://tildesoft.com/Programs.html#BonjourBrowser"&gt;Bonjour Browser&lt;/a&gt; software. It enables you to view all of the Bonjour…&lt;/p&gt;</description><link>http://blog.eridi.us/post/95024255</link><guid>http://blog.eridi.us/post/95024255</guid><pubDate>Fri, 10 Apr 2009 18:15:40 -0700</pubDate></item><item><title>DNS-SD Browser</title><description>&lt;a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=305441017&amp;mt=8"&gt;DNS-SD Browser&lt;/a&gt;: &lt;p&gt;DNS-SD Browser has finally been released in the iTunes AppStore. This is the iPhone version of my popular desktop Bonjour Browser application.&lt;/p&gt;</description><link>http://blog.eridi.us/post/95006616</link><guid>http://blog.eridi.us/post/95006616</guid><pubDate>Fri, 10 Apr 2009 16:57:00 -0700</pubDate><category>Bonjour</category><category>iTunes</category><category>iPhone</category><category>AppStore</category></item><item><title>The latest screenshot of the upcoming Diablo 3</title><description>&lt;img src="http://30.media.tumblr.com/103Dv3sXpje8xdpzGW7J20F3o1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;The latest screenshot of the upcoming Diablo 3&lt;/p&gt;</description><link>http://blog.eridi.us/post/74610962</link><guid>http://blog.eridi.us/post/74610962</guid><pubDate>Sat, 31 Jan 2009 11:53:04 -0800</pubDate><category>humor</category><category>diablo</category><category>screenshot</category></item><item><title>iPhone Protip: Fake navbar buttons</title><description>&lt;p&gt;If you need to have a third button in your navigation bar, you’ve probably discovered already that you can’t add a UIBarButtonItem as you only have 2 slots for those, on the left and the right. There’s the &lt;code&gt;titleView&lt;/code&gt; property, but you need to provide your own view and UIButton doesn’t have a style for bar buttons.&lt;/p&gt;

&lt;p&gt;However, there is a reasonably easy solution. UISegmentedControl has a bar style that looks exactly like one of the buttons. The only problem is it doesn’t behave like a button. However, you can make a simple subclass that overrides the &lt;code&gt;-touchesBegan:withEvent:&lt;/code&gt; and friends methods in order to make it behave like one after all. Now you can stick that in &lt;code&gt;titleView&lt;/code&gt; and it looks just fine.&lt;/p&gt;

&lt;p&gt;If you want it to be right-aligned on the bar, there’s another simple trick. Just create a UIView, set its &lt;code&gt;frame&lt;/code&gt; to the &lt;code&gt;bounds&lt;/code&gt; of the navbar, set your button as a subview right-aligned in the view and set the &lt;code&gt;autoresizeMask&lt;/code&gt; to keep it there. UINavigationBar will resize the titleView to fill all the remaining space, which will mean your button is now right-aligned right next to the &lt;code&gt;rightBarButtonItem&lt;/code&gt;.&lt;/p&gt;</description><link>http://blog.eridi.us/post/72316660</link><guid>http://blog.eridi.us/post/72316660</guid><pubDate>Thu, 22 Jan 2009 05:46:06 -0800</pubDate><category>iPhone</category><category>programming</category><category>protip</category></item><item><title>iPhone Protip: nib top-level objects</title><description>&lt;p&gt;When UIViewController loads a nib file, it does &lt;i&gt;not&lt;/i&gt; retain all top-level objects in the nib (unlike MainWindow.nib where all top-level objects are retained). If you use top-level objects besides your view, you must make sure you implement the IBOutlets as retained properties.&lt;/p&gt;</description><link>http://blog.eridi.us/post/71753407</link><guid>http://blog.eridi.us/post/71753407</guid><pubDate>Tue, 20 Jan 2009 01:00:00 -0800</pubDate><category>iPhone</category><category>protip</category><category>programming</category></item><item><title>Star Wars: Retold (By Someone Who Hasn’t Seen It) [VIDEO]</title><description>&lt;iframe src="http://player.vimeo.com/video/2809991" width="400" height="225" frameborder="0"&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;&lt;a href="http://vimeo.com/2809991"&gt;Star Wars: Retold (By Someone Who Hasn’t Seen It) [VIDEO]&lt;/a&gt;&lt;/p&gt;</description><link>http://blog.eridi.us/post/70734609</link><guid>http://blog.eridi.us/post/70734609</guid><pubDate>Thu, 15 Jan 2009 11:58:00 -0800</pubDate></item><item><title>Prince of Persia (PS3)</title><description>&lt;a href="http://www.amazon.com/gp/product/B001G6062O?ie=UTF8&amp;tag=eridius-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B001G6062O"&gt;Prince of Persia (PS3)&lt;/a&gt;: &lt;p&gt;The latest Prince of Persia game is a fresh start for the Prince of Persia series, focusing more on acrobatics and puzzles than on combat. I’ve only just started playing today, but so far I can say I love the visual style, the voice acting is great, and the writing is good. If you liked Sands of Time, I definitely recommend this. And there’s a version for the Xbox 360 or PC as well if you don’t have a PS3.&lt;/p&gt;</description><link>http://blog.eridi.us/post/68436392</link><guid>http://blog.eridi.us/post/68436392</guid><pubDate>Sun, 04 Jan 2009 22:17:00 -0800</pubDate></item><item><title>Just picked up Tumblrette and turned off auto-posting of my Twitter stream. Hopefully I’ll now...</title><description>&lt;p&gt;Just picked up Tumblrette and turned off auto-posting of my Twitter stream. Hopefully I’ll now actually post things.&lt;/p&gt;</description><link>http://blog.eridi.us/post/67204165</link><guid>http://blog.eridi.us/post/67204165</guid><pubDate>Sun, 28 Dec 2008 14:40:05 -0800</pubDate></item><item><title>Sitting in Sanders Theatre waiting for the Christmas Revels to start. And it looks like Yo Yo Ma is...</title><description>&lt;p&gt;Sitting in Sanders Theatre waiting for the Christmas Revels to start. And it looks like Yo Yo Ma is in the audience!&lt;/p&gt;</description><link>http://blog.eridi.us/post/67063719</link><guid>http://blog.eridi.us/post/67063719</guid><pubDate>Sat, 27 Dec 2008 15:03:27 -0800</pubDate></item><item><title>Installing World of Warcraft on my laptop so I can get my present from Grandfather Winter later</title><description>&lt;p&gt;Installing World of Warcraft on my laptop so I can get my present from Grandfather Winter later&lt;/p&gt;</description><link>http://blog.eridi.us/post/66754149</link><guid>http://blog.eridi.us/post/66754149</guid><pubDate>Thu, 25 Dec 2008 09:01:07 -0800</pubDate></item><item><title>Merry Christmas!</title><description>&lt;p&gt;Merry Christmas!&lt;/p&gt;</description><link>http://blog.eridi.us/post/66754147</link><guid>http://blog.eridi.us/post/66754147</guid><pubDate>Thu, 25 Dec 2008 09:01:06 -0800</pubDate></item></channel></rss>

