<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Ole Begemann: iOS Development</title>
	
	<link>http://oleb.net</link>
	<description>iOS SDK, Cocoa and Objective-C</description>
	<lastBuildDate>Fri, 25 Jun 2010 20:36:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ole-begemann-dev-blog" /><feedburner:info uri="ole-begemann-dev-blog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>52.518333</geo:lat><geo:long>13.408333</geo:long><item>
		<title>WWDC 2010 videos already available. And free!</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/c-_UZif1gR4/</link>
		<comments>http://oleb.net/blog/2010/06/wwdc-2010-videos-already-available-and-free/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 22:33:30 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=604</guid>
		<description><![CDATA[Apple has already posted the videos recorded at WWDC last week. And what&#8217;s even more incredible: they are downloadable for free at http://developer.apple.com/videos/wwdc/2010/ for registered Apple developers! Last year&#8217;s videos were only free for WWDC attendees and were priced $299 (iPhone sessions only) or $499 (iPhone and Mac sessions) for the rest of us. And [...]]]></description>
			<content:encoded><![CDATA[<p>Apple has already posted the videos recorded at WWDC last week. And what&#8217;s even more incredible: they are downloadable for free at <a href="http://developer.apple.com/videos/wwdc/2010/">http://developer.apple.com/videos/wwdc/2010/</a> for registered Apple developers! Last year&#8217;s videos were only free for WWDC attendees and were priced $299 (iPhone sessions only) or $499 (iPhone and Mac sessions) for the rest of us. And even at that price they were worth it. If you are serious about iOS development, do yourself a favor and watch as much of these 100 hours of material as possible. You are guaranteed to learn a lot.</p>
<p><a href="http://developer.apple.com/videos/wwdc/2010/"><img class="alignnone size-full wp-image-606" title="WWDC 2010 Videos available screenshot" src="http://oleb.net/wordpress/wp-content/media/wwdc-2010-videos-available-600x543.jpg" alt="WWDC 2010 Videos available screenshot" width="600" height="543" /></a></p>
<p>PS: Keep in mind that the contents of the videos are still confidential, just as they were for WWDC attendees. Apple will not be amused if we share any non-public information we learn from the sessions.</p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/c-_UZif1gR4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/06/wwdc-2010-videos-already-available-and-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/06/wwdc-2010-videos-already-available-and-free/</feedburner:origLink></item>
		<item>
		<title>App Store-safe Page Curl animations</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/zgkNfJGEIV0/</link>
		<comments>http://oleb.net/blog/2010/06/app-store-safe-page-curl-animations/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 18:20:33 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=592</guid>
		<description><![CDATA[Even if its usefulness is questionable, the page curl has become one of the signature effects of Apple&#8217;s iOS devices so it is no surprise that many developers would like to implement this effect in their apps. Apple uses private APIs The problem is that the page curl animation used by Apple is not exposed [...]]]></description>
			<content:encoded><![CDATA[<p>Even if its usefulness is questionable, the page curl has become one of the signature effects of Apple&#8217;s iOS devices so it is no surprise that many developers would like to implement this effect in their apps.</p>
<div id="attachment_595" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-595" title="iBooks screenshot during page curl" src="http://oleb.net/wordpress/wp-content/media/iBooks-page-curl-screenshot-600x438.png" alt="iBooks screenshot during page curl" width="600" height="438" /><p class="wp-caption-text">iBooks on the iPad doing a page curl</p></div>
<h3>Apple uses private APIs</h3>
<p>The problem is that the page curl animation used by Apple is not exposed in a public and documented API. Steven Troughton-Smith did a great job at documenting how Apple&#8217;s implementation works in his post <a href="http://blog.steventroughtonsmith.com/2010/02/apples-ibooks-dynamic-page-curl.html">Apple&#8217;s iBooks Dynamic Page Curl</a>. Although Steven&#8217;s sample code is a bit rough (as Steven himself admits), the inner workings become clear: Apple has written a custom <a href="http://en.wikipedia.org/wiki/Core_image">Core Image</a> filter that is accessible with the undocumented kCAFilterPageCurl constant. (Yeah I know, Apple actually <a title="CALayer Class Reference: filters property" href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004500-CH1-SW51">tells us in the documentation</a> that &#8220;Core Image is not available in iPhone OS&#8221;. They lied.)</p>
<p>This filter accepts to input values, <code>inputAngle</code> and <code>inputTime</code>, to control the angle from which the layer is curled up and the magnitude of the curl. For a page curl animation, we would animate <code>inputTime</code> from <code>0.0f</code> to <code>1.0f</code>. To attach the filter to a layer, simply add it to an array and assign the array to the layer&#8217;s <code>filters</code> property (ignoring that the documentation says this leads to undefined behavior. In this case, undefined behavior is exactly what we want.).</p>
<p>From Steven&#8217;s code (edited for clarity):</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@class</span> CAFilter;
<span style="color: #a61390;">extern</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>kCAFilterPageCurl; <span style="color: #11740a; font-style: italic;">// From QuartzCore.framework</span>
&nbsp;
<span style="color: #a61390;">static</span> CAFilter <span style="color: #002200;">*</span>filter <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
&nbsp;
...
&nbsp;
<span style="color: #11740a; font-style: italic;">// In -touchesMoved:</span>
filter <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CAFilter filterWithType<span style="color: #002200;">:</span>kCAFilterPageCurl<span style="color: #002200;">&#93;</span> retain<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>filter setDefaults<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>filter setValue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithFloat<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>NSUInteger<span style="color: #002200;">&#41;</span>fingerDelta<span style="color: #002200;">&#41;</span><span style="color: #002200;">/</span><span style="color: #2400d9;">100.0</span><span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;inputTime&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
CGFloat _angleRad <span style="color: #002200;">=</span> angleBetweenCGPoints<span style="color: #002200;">&#40;</span>currentPos, lastPos<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#91;</span>filter setValue<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithFloat<span style="color: #002200;">:</span>_angleRad<span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;inputAngle&quot;</span><span style="color: #002200;">&#93;</span>;
pageView.layer.filters <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObject<span style="color: #002200;">:</span>filter<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h3>The App Store-safe way</h3>
<p>I hope Apple makes this public in the future (and if you want to have it, too, you should <a href="http://bugreport.apple.com/">file a bug</a> and request it). In the meantime, <a href="http://tombrow.com/">Tom Brow</a> has written <a href="http://github.com/brow/leaves">Leaves</a>, a simple component that achieves a page curl effect through a very smart combination of mirrored and shaded layers (for translucent pages) and gradient layers (for shadows). Basically, Tom adds to the layer that contains the page content (<code>topPage</code>):</p>
<ol>
<li>an overlay to shade the page during the curl animation (<code>topPageOverlay</code>),</li>
<li>a gradient layer that acts as the top page&#8217;s shadow during the curl (<code>topPageShadow</code>),</li>
<li>a mirrored image of the page that will be displayed on the back of the topPage layer during the curl (<code>topPageReverseImage</code>),</li>
<li>a nearly-white overlay to soften the <code>topPageReverseImage</code>,</li>
<li>and the page below the current page that will become the new <code>topPage</code> after the curl has finished.</li>
</ol>
<p>The end result is not quite as stunning as Apple&#8217;s solution but it is a very good workaround.</p>
<p>As I played around with Tom&#8217;s code (I encourage you to take a look at it, it is very clean), I noticed that <code>LeavesView</code> did not support displaying two pages side by side in landscape mode, so I modified Tom&#8217;s code accordingly. At first, I planned to duplicate the entire layer hierarchy for the second page, but then I noticed that even in the side-by-side view it is enough if only the page on the right is animated. It was enough to add a <code>leftPage</code> layer, modify the page skipping algorithm (skip two pages instead of one) and the display of the <code>topPageReverseImage</code> layer (display an image of the next page instead a mirrored image of the current page). This is what you get:</p>
<div id="attachment_599" class="wp-caption alignnone" style="width: 610px"><img class="size-full wp-image-599" title="Leaves project page curl screenshot" src="http://oleb.net/wordpress/wp-content/media/leaves-page-curl-screenshot-600x438.png" alt="Leaves project page curl screenshot" width="600" height="438" /><p class="wp-caption-text">Page curl in the Leaves project in side-by-side view</p></div>
<p>The code is not yet perfect: the <code>topPageShadow</code> is not aligned correctly and I struggled a bit with Tom&#8217;s implementation of the page image cache so the code in that section is quite rough. Tom has not yet integrated my modifications into his repository but you can already <a href="http://github.com/ole/leaves/tree/twopages">check out my twopages branch</a> (I love GitHub!). When there is time, I hope we can improve it even more.</p>
<p><strong>Update June 21, 2010: John from maniacdev.com made a </strong><a href="http://maniacdev.com/2010/06/lick-ibooks-like-page-turning-effect/"><strong>nice screencast of the effect in action</strong></a><strong>. Thanks!</strong></p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/zgkNfJGEIV0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/06/app-store-safe-page-curl-animations/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/06/app-store-safe-page-curl-animations/</feedburner:origLink></item>
		<item>
		<title>UIWebView’s weird PDF display bug on the iPad</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/AGf-DC6Lg_A/</link>
		<comments>http://oleb.net/blog/2010/06/uiwebview-weird-pdf-display-bug-on-ipad/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 08:00:08 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=580</guid>
		<description><![CDATA[UIWebView seems to have a weird display bug connected to PDFs and interface rotation in iPhone SDK 3.2. This is how a PDF displayed in a UIWebView looks on the iPad after you rotate the device from portrait to landscape: The PDF appears to be split in half vertically along an edge that was right [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://developer.apple.com/iphone/library/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html">UIWebView</a> seems to have a weird display bug connected to PDFs and interface rotation in iPhone SDK 3.2. This is how a PDF displayed in a UIWebView looks on the iPad after you rotate the device from portrait to landscape:</p>
<div id="attachment_581" class="wp-caption alignnone" style="width: 330px"><a href="http://oleb.net/wordpress/wp-content/media/uiwebview-pdf-display-bug-screenshot.png"><img class="size-medium wp-image-581" title="UIWebView PDF display bug on the iPad (iPhone SDK 3.2)" src="http://oleb.net/wordpress/wp-content/media/uiwebview-pdf-display-bug-screenshot-320x246.png" alt="UIWebView PDF display bug on the iPad" width="320" height="246" /></a><p class="wp-caption-text">UIWebView PDF display bug on the iPad (iPhone SDK 3.2)</p></div>
<p>The PDF appears to be split in half vertically along an edge that was right in the middle of the page while the device was in portrait orientation. The right half is vertically offset from the left half. <a href="http://stackoverflow.com/questions/2660578/ipad-uiwebview-pdf-rendering-is-giving-me-weird-visual-artifacts">Other people have also noticed it</a> so I believe it is a genuine bug.</p>
<p>To reproduce it, try the following:</p>
<ol>
<li>Create a UIWebView and set <code>scalesPageToFit = YES</code>.</li>
<li>Embed the web view in a view controller that supports both portrait and landscape orientation.</li>
<li>Load a PDF file into the web view.</li>
<li>Rotate the iPad from portrait to landscape or vice versa.</li>
</ol>
<p>Or <a title="PDFDisplayBugDemo sample project" href="http://oleb.net/wordpress/wp-content/media/PDFDisplayBugDemo.zip">download the sample project</a> I have created.</p>
<p>I can reproduce this consistently with a number of different PDF files using iPhone SDK 3.2 both in the iPad Simulator and on an actual iPad. The bug does not appear with HTML content nor is it present on the iPhone. It also disappears if you zoom into the page just a little bit or if you set <code>scalesPageToFit = NO</code>.</p>
<h3>Workaround: Reload the document after rotation</h3>
<p>The only workaround I have found so far is to reload the document after the device has been rotated. It is not very pretty because reloading can take some time and the user can still see the buggy display for a second, but other than that it works. The best place for the reloading code seems to be your view controller&#8217;s <code>-didRotateFromInterfaceOrientation:</code> method.</p>
<p>Reported to Apple as Radar #8065859.</p>
<p><strong>Update June 12, 2010: Apple has confirmed this bug as a duplicate to #7790957.</strong></p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/AGf-DC6Lg_A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/06/uiwebview-weird-pdf-display-bug-on-ipad/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/06/uiwebview-weird-pdf-display-bug-on-ipad/</feedburner:origLink></item>
		<item>
		<title>World Cup 2010 Tracker Spreadsheet</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/gzw33t31TqU/</link>
		<comments>http://oleb.net/blog/2010/06/world-cup-2010-spreadsheet/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 10:18:31 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=571</guid>
		<description><![CDATA[Update June 25, 2010: Now that the group stage is over I have updated the spreadsheet with the results of all the group stage games. If you download it now, you can dive right into the knockout stage. Update June 7, 2010: There is a bug in the first version of the spreadsheet that results [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update June 25, 2010: Now that the group stage is over I have updated the spreadsheet with the results of all the group stage games. If you download it now, you can dive right into the knockout stage.</strong></p>
<p><strong>Update June 7, 2010: There is a bug in the first version of the spreadsheet that results in a wrong team being selected for the seventh game in the Round of 16. Thanks to <a href="http://twitter.com/galdo">@galdo</a> for pointing it out. The download link below points to a fixed version.</strong></p>
<p>I haven&#8217;t had the need to use a spreadsheet since I quit my job a few years ago, but after getting the iPad I wanted to try out Numbers and so I built a spreadsheet for tracking the 2010 World Cup yesterday. Inspired by Fraser Speirs, who published <a href="http://speirs.org/blog/2010/5/31/world-cup-tracker-spreadsheet.html">his World Cup Tracker Spreadsheet</a> last week. Since Fraser&#8217;s version requires a little bit of manual effort (it doesn&#8217;t automatically determine the winners of the group stage), I thought I could do better and make it fully automatic. I hope you like it:</p>
<p>Download: <a href="http://oleb.net/wordpress/wp-content/media/WorldCup2010.numbers">World Cup 2010 Spreadsheet for Numbers</a> (1.4 MB)</p>
<p><a href="http://oleb.net/wordpress/wp-content/media/world-cup-2010-spreadsheet-screenshot-1.png"><img title="World Cup 2010 Spreadsheet Screenshot 1" src="http://oleb.net/wordpress/wp-content/media/world-cup-2010-spreadsheet-screenshot-1-240x320.png" alt="World Cup 2010 Spreadsheet Screenshot 1" width="240" height="320" /></a> <a href="http://oleb.net/wordpress/wp-content/media/world-cup-2010-spreadsheet-screenshot-2.png"><img class="alignnone size-medium wp-image-574" title="World Cup 2010 Spreadsheet Screenshot 2" src="http://oleb.net/wordpress/wp-content/media/world-cup-2010-spreadsheet-screenshot-2-320x240.png" alt="World Cup 2010 Spreadsheet Screenshot 2" width="320" height="240" /></a></p>
<p>All you need to do is enter the scores for each on the fixtures sheets (one sheet per group) and, later, on the Knockout Stage sheet. The trickiest part of automating the calculation of the group rankings are the complicated <a href="http://en.wikipedia.org/wiki/2010_FIFA_World_Cup#Tie-breaking_criteria">tie-breaking criteria</a>. To rank the teams, the spreadsheet considers the number of points, the goal difference, and the number of goals scored. If two or more teams are still tied on these criteria, the calculation will break. Let&#8217;s just hope that won&#8217;t happen. (FIFA then considers the match(es) between the teams to break the tie.)</p>
<p>(Beware: I haven&#8217;t tested the spreadsheet very thoroughly so there might well be some bugs in the formulas. If you find one, please tell me and I&#8217;ll fix it.)</p>
<p><strong>Thoughts on Numbers on the iPad</strong></p>
<p>We already know that the iPad is far more than a consumption-only device and that it has a lot of potential for content creation, as well. That said, it took me a lot longer to build this spreadsheet on the iPad than it would have with Excel or Numbers on a &#8220;real&#8221; computer. I spent about 4 hours to make this yesterday and I estimate that I could have gotten the same result in about 1 hour with a desktop app. I think the main reasons for this discrepancy are:</p>
<ul>
<li>The iPad&#8217;s smaller screen makes it harder to navigate and formatting your content takes more time as you always have to switch back and forth between your content and the inspector.</li>
<li>The touch interface is just not as well suited to a spreadsheet app as mouse and keyboard (with powerful keyboard shortcuts) are.</li>
<li>As amazing as it is how much functionality Apple managed to put into Numbers on the iPad, it does lack some key functionality (to me), namely multiple selections and the ability to move content between tables without breaking the references (dragging between tables does not work and cutting-and-pasting breaks the references).</li>
</ul>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/gzw33t31TqU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/06/world-cup-2010-spreadsheet/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/06/world-cup-2010-spreadsheet/</feedburner:origLink></item>
		<item>
		<title>How to debug an app that was launched by Push Notification or URL handler</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/XfZnCteDUhI/</link>
		<comments>http://oleb.net/blog/2010/05/how-to-debug-app-launched-by-remote-event/#comments</comments>
		<pubDate>Thu, 06 May 2010 21:17:05 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=562</guid>
		<description><![CDATA[I&#8217;ve been fairly active on Stack Overflow lately. To date, I have answered 315 questions there and while I haven&#8217;t asked any questions myself, I have profited immensely from the knowledge others have shared there. It is truly a great site, so much better than most programming forums. I think many questions that I have [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been fairly active on <a href="http://stackoverflow.com/">Stack Overflow</a> lately. To date, I have <a href="http://stackoverflow.com/users/116862/ole-begemann">answered 315 questions</a> there and while I haven&#8217;t asked any questions myself, I have profited immensely from the knowledge others have shared there. It is truly a great site, so much better than most programming forums. I think many questions that I have answered might also be interesting to you and so I thought I&#8217;d share some of the more interesting ones (and the answers, of course) here, perhaps with a little more detail than on SO.</p>
<p>Let&#8217;s start with this one: <a href="http://stackoverflow.com/questions/454188/how-do-you-debug-your-application-if-they-got-started-using-a-custom-url-scheme/">How can I debug an app that was started by an external event such as a push notification or a URL handler?</a> You don&#8217;t click on Build and Debug in these cases, so how do we get the debugger to notice? You have two options here:</p>
<h3>1. Use NSLog statements and inspect them in Console.app</h3>
<p>The output of your <code>NSLog()</code> calls not only show up in the Debugger Console in Xcode but also in the system logs. To look up the logs for the simulator (useful for testing a custom URL scheme), open Console.app in OS X, select Console Messages in the left pane and then search for the name of your app in the Filter field. To see the Console messages on the device (e.g. to test how your app handles an incoming push notification), open the Organizer in Xcode, select your device and switch to the Console app before your app gets launched.</p>
<h3>2. Ask the debugger to wait for your app to launch</h3>
<p>Sometimes, <code>NSLog()</code> is just not enough and you want the full power of the debugger. No problem:</p>
<ol>
<li>Set a breakpoint where you want it e.g. in <code>application:didFinishLaunchingWithOptions:</code>.</li>
<li>Select Project &gt; Edit Active Executable. On the Debugging tab, select the &#8220;Wait for next launch/push notification&#8221; checkbox:<br />
<img class="alignnone size-full wp-image-563" title="Xcode Active Executable Settings: Debugging, wait for next launch" src="http://oleb.net/wordpress/wp-content/media/xcode-active-executable-debugging-wait-for-next-launch.png" alt="Xcode Active Executable Settings: Debugging, wait for next launch" width="442" height="593" /></li>
<li>Build and Debug as you normally would. The Console will show you a message that the debugger is waiting for your app to launch.<br />
<img class="alignnone size-full wp-image-565" title="Xcode: Debugger waiting for app to launch" src="http://oleb.net/wordpress/wp-content/media/xcode-debugger-waiting-for-app-to-launch.png" alt="Xcode: Debugger waiting for app to launch" width="529" height="179" /></li>
<li>Launch your app by invoking your custom URL or sending a push notification. The debugger will automatically attach to your app&#8217;s process and stop at the breakpoint.</li>
</ol>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/XfZnCteDUhI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/05/how-to-debug-app-launched-by-remote-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/05/how-to-debug-app-launched-by-remote-event/</feedburner:origLink></item>
		<item>
		<title>iPhone SDK Beta to Beta API Diffs</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/LEKz9wOq-sI/</link>
		<comments>http://oleb.net/blog/2010/05/iphone-sdk-beta-to-beta-api-diffs/#comments</comments>
		<pubDate>Tue, 04 May 2010 20:23:30 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=558</guid>
		<description><![CDATA[Apple released a new beta version of the iPhone SDK today. So what changed from the last beta, you ask? It&#8217;s a little hard to tell from the links Apple provides on their developer website because the link to the API diffs (iPhone developer account required) always lists all changes from the most recent stable [...]]]></description>
			<content:encoded><![CDATA[<p>Apple released a new beta version of the iPhone SDK today. So what changed from the last beta, you ask? It&#8217;s a little hard to tell from the links Apple provides on their developer website because <a title="iPhone OS 3.2 to iPhone OS 4.0 beta API diffs" href="http://developer.apple.com/iphone/prerelease/library/releasenotes/General/iPhone40APIDiffs/index.html">the link to the API diffs</a> (iPhone developer account required) always lists <em>all</em> changes from the most recent stable version. So if you have already downloaded beta 1 and beta 2, you are now reading the same document for the third time. Thankfully, Apple also provides a documents that only lists the changes from the last beta version, but it is not listed on the developer home page:</p>
<p><a title="iPhone OS Beta to Beta API diffs" href="https://developer.apple.com/iphone/prerelease/library/releasenotes/General/iPhoneSeedAPIDiffs/index.html">https://developer.apple.com/iphone/prerelease/library/releasenotes/General/iPhoneSeedAPIDiffs/index.html</a> (iPhone developer account required)</p>
<p>This URL seems to remain constant between beta releases. In other words, it always lists the differences between the most recent beta release and its predecessor. If you follow the SDK betas it&#8217;s a good idea to bookmark that page.</p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/LEKz9wOq-sI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/05/iphone-sdk-beta-to-beta-api-diffs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/05/iphone-sdk-beta-to-beta-api-diffs/</feedburner:origLink></item>
		<item>
		<title>Set the zoom level of MKMapView</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/_ndr_yACKo8/</link>
		<comments>http://oleb.net/blog/2010/05/set-the-zoom-level-of-mkmapview/#comments</comments>
		<pubDate>Mon, 03 May 2010 16:48:07 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=554</guid>
		<description><![CDATA[A very nice MKMapView category by Troy Brant that allows you to zoom the map by settting the zoom level (as in the Javascript Google Maps API) in addition to Apple&#8217;s way of zooming by modifying the map&#8217;s region: Unfortunately, MapKit on the iPhone does not include a way to set the zoom level. Instead, [...]]]></description>
			<content:encoded><![CDATA[<p>A <a title="Set the Zoom Level of an MKMapView" href="http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/">very nice MKMapView category</a> by Troy Brant that allows you to zoom the map by settting the zoom level (as in the <a href="http://code.google.com/apis/maps/">Javascript Google Maps API</a>) in addition to Apple&#8217;s way of zooming by modifying the map&#8217;s region:</p>
<blockquote><p>Unfortunately, MapKit on the iPhone does not include a way to set the zoom level. Instead, the zoom level is set implicitly by defining the <code>MKCoordinateRegion</code> of the map’s viewport. When initializing the region, you specify the amount of distance the map displays in the horizontal and vertical directions. The zoom level is set implicitly based on these distance values.</p>
<p>Instead of dealing with this region business, I wrote a category that adds support for setting the zoom level of an <code>MKMapView</code> explicitly.</p></blockquote>
<p>Troy also wrote an <a title="MKMapView and Zoom Levels: A Visual Guide" href="http://troybrant.net/blog/2010/01/mkmapview-and-zoom-levels-a-visual-guide/">extensively detailed post on the mathematical background</a> of his code. Great stuff!</p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/_ndr_yACKo8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/05/set-the-zoom-level-of-mkmapview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/05/set-the-zoom-level-of-mkmapview/</feedburner:origLink></item>
		<item>
		<title>I’m available for contract work</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/o1AJkCmuQ94/</link>
		<comments>http://oleb.net/blog/2010/04/available-for-contract-work/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 09:43:54 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=550</guid>
		<description><![CDATA[As of now, I am available for contract work developing iPhone and/or iPad apps. If you are looking for an experienced developer who already published an iPad app and a very successful iPhone app (Songtext was the top paid app on the Germany App Store), please e-mail me at ole@oleb.net. I look forward to discussing [...]]]></description>
			<content:encoded><![CDATA[<p>As of now, I am available for contract work developing iPhone and/or iPad apps. If you are looking for an experienced developer who already published <a title="Picture Effects for iPhone and iPad" href="http://pictureeffectsapp.com">an iPad app</a> and a very successful iPhone app (<a href="http://songtextapp.com">Songtext</a> was the top paid app on the Germany App Store), please e-mail me at <a href="mailto:ole@oleb.net">ole@oleb.net</a>. I look forward to discussing your projects with you. I am based in Berlin but working remotely or travelling would be no problem.</p>
<p><em>Ich bin ab sofort auch für Freelance-Aufträge als iPhone- und iPad-Entwickler verfügbar. Wenn Sie einen erfahrenen Entwickler suchen, der bereits <a title="Picture Effects für iPhone und iPad" href="http://pictureeffectsapp.com">eine iPad-App</a> und eine sehr erfolgreiche iPhone-App (<a href="http://songtextapp.com">Songtext</a> war für einige Zeit die Nr. 1 im deutschen App Store) veröffentlicht hat, kontaktieren Sie mich bitte unter <a href="mailto:ole@oleb.net">ole@oleb.net</a>. Ich wohne in Berlin, bin aber auch für auswärtige Projekte offen.</em></p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/o1AJkCmuQ94" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/available-for-contract-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/available-for-contract-work/</feedburner:origLink></item>
		<item>
		<title>OBGradientView: a simple UIView wrapper for CAGradientLayer</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/rKhVlrzWMaM/</link>
		<comments>http://oleb.net/blog/2010/04/obgradientview-a-simple-uiview-wrapper-for-cagradientlayer/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 12:15:32 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=542</guid>
		<description><![CDATA[CAGradientLayer is the simplest way to display gradients on the iPhone. And while Core Animation layers are simple enough to use, I repeatedly find myself missing the ability to simply add a gradient directly to a view (as a replacement for its background color) without having to write the code to manually add a CAGradientLayer [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CAGradientLayer_class/Reference/Reference.html"><code>CAGradientLayer</code></a> is the simplest way to display gradients on the iPhone. And while Core Animation layers are simple enough to use, I repeatedly find myself missing the ability to simply add a gradient directly to a view (as a replacement for its background color) without having to write the code to manually add a CAGradientLayer to the view. So I wrote a little class that does just that.</p>
<p><a title="OBGradientView on GitHub" href="http://github.com/ole/OBGradientView"><code>OBGradientView</code></a> is a very simple UIView subclass that wraps the functionality of CAGradientLayer in a view. It exposes all of the layer&#8217;s gradient-related properties (<code>colors</code>, <code>locations</code>, <code>startPoint</code>, <code>endPoint</code>, and <code>type</code>) as its own properties. Calls of the setters and getters are simply forwarded to the underlying CAGradientLayer so you can use the same syntax to define the gradient. In addition, to make it more UIKit-friendly, OBGradientView allows you to set the <code>colors</code> property with an array of <code>UIColor</code> instances instead of <code>CGColorRef</code>s.</p>
<p>Dealing with a view instead of a Core Animation layer is especially useful when you want to use autoresizing masks, which are not available for CALayer on the iPhone. For example, adding a subtle background gradient to your view controller&#8217;s main view that autoresizes automatically is very simple:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">OBGradientView <span style="color: #002200;">*</span>backgroundGradient <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>OBGradientView alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>self.view.bounds<span style="color: #002200;">&#93;</span>;
backgroundView.colors <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>UIColor lightGrayColor<span style="color: #002200;">&#93;</span>, 
                         <span style="color: #002200;">&#91;</span>UIColor darkGrayColor<span style="color: #002200;">&#93;</span>, 
                         <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
backgroundView.autoresizingMask <span style="color: #002200;">=</span> UIViewAutoresizingFlexibleWidth | 
                                  UIViewAutoresizingFlexibleHeight;</pre></div></div>

<p><a title="OBGradientView on GitHub" href="http://github.com/ole/OBGradientView">Get the code for OBGradientLayer from GitHub</a>. I am releasing it under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>.<br />
<a href="http://oleb.net/wordpress/wp-content/media/OBGradientViewDemo-screenshot.png"><img src="http://oleb.net/wordpress/wp-content/media/OBGradientViewDemo-screenshot-213x320.png" alt="Screenshot of the OBGradientViewDemo project" title="OBGradientViewDemo-screenshot" width="213" height="320" class="alignnone size-medium wp-image-546" /></a></p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/rKhVlrzWMaM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/obgradientview-a-simple-uiview-wrapper-for-cagradientlayer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/obgradientview-a-simple-uiview-wrapper-for-cagradientlayer/</feedburner:origLink></item>
		<item>
		<title>Picture Effects is now $0.99</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/ZhBT09TEDqM/</link>
		<comments>http://oleb.net/blog/2010/04/picture-effects-is-now-99-cents/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 20:54:31 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=528</guid>
		<description><![CDATA[I have lowered the price for Picture Effects to $0.99 today, so now is a great chance to get it. This is basically an experiment for myself to see how sales will develop compared to the former price tag of $2.99. I haven&#8217;t yet determined how long it will last. I&#8217;ll leave the price at [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_532" class="wp-caption alignright" style="width: 209px"><a href="http://pictureeffectsapp.com/"><img class="size-full wp-image-532" title="pictureeffectsapp.com screenshot" src="http://oleb.net/wordpress/wp-content/media/pictureeffectsapp-com-screenshot-e1271191854470.png" alt="pictureeffectsapp.com screenshot" width="199" height="595" /></a><p class="wp-caption-text">The new web site</p></div>
<p>I have lowered the price for <a href="http://pictureeffectsapp.com/">Picture Effects</a> to $0.99 today, so now is a great chance to get it. This is basically an experiment for myself to see how sales will develop compared to the former price tag of $2.99. I haven&#8217;t yet determined how long it will last. I&#8217;ll leave the price at $0.99 for at least a week and then reevaluate. I think it&#8217;s really good value, especially if you consider that Picture Effects is a universal app. I still haven&#8217;t had the chance to see the app on an actual iPad myself, but from the feedback I&#8217;ve received it seems to work really well.</p>
<h3>Working on updates</h3>
<p>I&#8217;ve also been working on the first update that will bring some small UI improvements and a German translation. And to top it off, I improved the <a href="http://pictureeffectsapp.com/">pictureeffectsapp.com</a> site today. The design is now cleaner, I added a screencast of the iPhone version in action, and I switched from embedded YouTube videos to HTML 5 video elements. Now the site renders very nicely on the iPad, too (at least on the iPad Simulator).</p>
<h3>Can I ask you for a customer review?</h3>
<p>If you have purchased Picture Effects and you would like to see it improve in the future, could I kindly ask you to <a title="Leave a review for Picture Effects on the App Store" href="https://userpub.itunes.apple.com/WebObjects/MZUserPublishing.woa/wa/addUserReview?id=362066808&amp;type=Purple+Software">leave an honest rating and/or review on the App Store</a>? Having a number of meaningful reviews would help me tremendously in getting more exposure to Picture Effects. Thank you very much!</p>
<div style="clear:both;"></div>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/ZhBT09TEDqM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/picture-effects-is-now-99-cents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/picture-effects-is-now-99-cents/</feedburner:origLink></item>
		<item>
		<title>How to specify two icons for a universal iPhone/iPad app</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/rIPIi-T-xVM/</link>
		<comments>http://oleb.net/blog/2010/04/two-icons-for-universal-iphone-ipad-app/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 15:15:06 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=520</guid>
		<description><![CDATA[The icon of an iPhone app must be 57×57 pixels, and iPad app icons must be 72&#215;72 pixels. How to specify both icons in your Info.plist, given that the CFBundleIconFile property only allows one value? Apple&#8217;s documentation on this is a little hard to find but the solution is very simple: add a CFBundleIconFiles (note [...]]]></description>
			<content:encoded><![CDATA[<p>The icon of an iPhone app must be 57×57 pixels, and iPad app icons must be 72&#215;72 pixels. How to specify both icons in your <code>Info.plist</code>, given that the <code>CFBundleIconFile</code> property only allows one value?</p>
<p><a href="http://developer.apple.com/iphone/library/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-SW10" title="Information Property List Key Reference: CFBundleIconFiles">Apple&#8217;s documentation on this</a> is a little hard to find but the solution is very simple: add a <code>CFBundleIconFiles</code> (note the plural) key of type Array to your <code>Info.plist</code>. The items in the array should be string values containing the filenames of all the icons your app needs. In a universal app, you should provide at least the two main icons (57×57 and 72×72). Optionally, you can also add two smaller icons used for your app in the Settings app and Spotlight search. These should be 29×29 pixels for the iPhone and 48×48 for the iPad.</p>
<p><img src="http://oleb.net/wordpress/wp-content/media/picture-effects-info-plist-cfbundleiconfiles.png" alt="CFBundleIconFiles key in Info.plist" title="CFBundleIconFiles key in Info.plist" width="529" height="227" class="alignnone size-full wp-image-521" /></p>
<p>The filenames of the icons and the order of the items in the array are arbitray. The system automatically chooses the file with the correct dimensions based on the device type. You should keep the <code>CFBundleIconFile</code> key and have it point to your iPhone icon for 3.0/3.1 compatibility.</p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/rIPIi-T-xVM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/two-icons-for-universal-iphone-ipad-app/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/two-icons-for-universal-iphone-ipad-app/</feedburner:origLink></item>
		<item>
		<title>New opportunities for developers in iPhone OS 4.0</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/NSlL-d7Mrl4/</link>
		<comments>http://oleb.net/blog/2010/04/new-opportunities-for-developers-in-iphone-os-4-0/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 12:36:16 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=504</guid>
		<description><![CDATA[It&#8217;s always a good idea to build apps that make use of new features when they come out. Competition is likely to be less fierce in the beginning, and since Apple is likely to introduce those features that have been requested most by users or have been deemed most interesting by Apple&#8217;s own market research, [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s always a good idea to build apps that make use of new features when they come out. Competition is likely to be less fierce in the beginning, and since Apple is likely to introduce those features that have been requested most by users or have been deemed most interesting by Apple&#8217;s own market research, you can count on the fact that there will be considerable user demand for the new functionality. So let&#8217;s have a look at the public information that we got from yesterday&#8217;s <a href="http://events.apple.com.edgesuite.net/1004fk8d5gt/event/">iPhone OS 4.0 introduction event</a> and what new app ideas could come out of it. Rather than talking about the things that Steve Jobs already highlighted in the presentation, I want to focus on some of the other new APIs that Apple showed us on this slide:</p>
<div id="attachment_505" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-505" title="Slide: New APIs in iPhone OS 4.0" src="http://oleb.net/wordpress/wp-content/media/iphone-os-4-0-slide-new-apis.png" alt="Slide: New APIs in iPhone OS 4.0" width="640" height="398" /><p class="wp-caption-text">Some of the new APIs in iPhone OS 4.0</p></div>
<h3>All things photos</h3>
<p>At the moment, third-party apps have no direct programmatic access to the user&#8217;s photo library. The only thing they can do is present an image picker to the user who can then pick one (and only one at a time) photo that gets forwarded to the app. If &#8220;Photo Library access&#8221; means what I think it means, namely full programmatic access to the photo library, it could enable us to build full-fledged photo organizing apps similar to iPhoto or even Aperture and Lightroom and thereby solve <a href="http://speirs.org/blog/2010/4/3/everything-changes.html">&#8220;The Photography Question&#8221;</a> (Fraser Speirs, see the bottom of that article). I hope the access to the Photo Library includes access to the images&#8217; EXIF metadata (which currently does not get through the image picker) and the ability to modify, create and delete photo albums.</p>
<p>We know that the iPad already supports photos in RAW format so with this addition I predict that an iPhoto-like app on the iPad will be a huge hit. The fact that Apple also mentions support for ICC profiles on the slide suggests that they really mean to provide everything that&#8217;s necessary to write a professional RAW converter for iPhone OS.</p>
<p>And though <a href="http://en.wikipedia.org/wiki/Core_Image">Core Image</a> isn&#8217;t mentioned and presumably not part of OS 4.0, the hardware-accelerated math library &#8220;Accelerate&#8221; that Steve Jobs mentioned could make it quite easy to write advanced photo filters with decent performance without having to resort to full OpenGL rendering (what I had to do in <a href="http://pictureeffectsapp.com">Picture Effects</a> to get realtime updating). I see a Photoshop clone for the iPad on the horizon.</p>
<h3>Full access to still and video camera data</h3>
<p>Direct access to the camera&#8217;s video feed can be used for:</p>
<ul>
<li>New forms of Augmented Reality apps (based on image recognition instead of sensor data).</li>
<li>Video chat (if we assume the next iPhone also gets a front-facing camera; if I were Skype, <a title="TUAW: iChatAgent process shows up in iPhone OS 4.0 -- video conferencing coming?" href="http://www.tuaw.com/2010/04/08/ichatagent-process-shows-up-in-iphone-os-4-0-video-conferenci/">I would count on it</a>).</li>
<li>Realtime manipulation of the live video. I will certainly look into this for Picture Effects. Hopefully it can become more like Photo Booth with effects being applied in realtime to the live video from the camera.</li>
<li>Better performance for Barcode scanning apps and others that currently have to rely on the private-but-tolerated <code>UIGetScreenImage()</code> API.</li>
<li>Apps like <a href="http://www.google.com/mobile/goggles/">Google Goggles</a>.</li>
</ul>
<h3>Calendar access and Local notifications</h3>
<p>Access to the device&#8217;s calendar has to be one of the most-requested features since day one of the iPhone SDK. Now that it is coming, it will make a lot of existing organizer apps even more useful. Assuming developers can not only read existing calendar entries but also have write access, that is. I see a lot of apps integrating web data (like events from <a href="http://upcoming.yahoo.com/">upcoming</a>, the match schedule of your favorite football team or the date of the next solar eclipse) with the calendar.</p>
<p>Many developers presumably asked Apple for a calendar API in order to schedule alarms at a certain time that worked even if their app was not running. Until now, you would have to use push notifications for this, with all the additional overhead that requires: you would have to maintain a server and your app would have to communicate with it. With iPhone OS 4.0, this is no longer necessary and you don&#8217;t even have to add your alarms to the calendar where they might confuse the user. Apple added local notifications that, from the user&#8217;s perspective, seem to work just like push notifications but don&#8217;t travel through the cloud. Presumably, your app just tells the notification service to alert the user at a specified date and that&#8217;s it. For example, a to-do app can use local notifications to tell you about a task that is due. A travel companion app could alert you when your train is about to arrive.</p>
<h3>Location-based alerts</h3>
<p>If I remember correctly, one of Android&#8217;s signature apps when it came out was a shopping list app that could remind you to buy groceries whenever your location was near the supermarket. Until now, apps like that weren&#8217;t possible on the iPhone, but with OS 4.0, you can use the low-power cell-tower-based background location service that Scott Forstall mentioned in the presentation. Same with a travel companion app that should alert you when you are on a train and your destination station comes up.</p>
<h3>What are your ideas?</h3>
<p>That&#8217;s it for my ideas of what new things we can do on iPhone OS 4.0. What are yours? Please share some in the comments. <a href="http://37signals.com/svn/posts/1122-i-had-that-idea-years-ago">Ideas are worthless</a>, after all. It&#8217;s the execution that counts.</p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/NSlL-d7Mrl4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/new-opportunities-for-developers-in-iphone-os-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/new-opportunities-for-developers-in-iphone-os-4-0/</feedburner:origLink></item>
		<item>
		<title>Apple bans cross-compilers for iPhone development</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/t51zBfLhJXA/</link>
		<comments>http://oleb.net/blog/2010/04/apple-bans-cross-compilers-for-iphone-development/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 09:13:16 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=497</guid>
		<description><![CDATA[John Gruber was the first to notice that Apple has apparently updated a crucial section of the iPhone Developer Agreement that practically crushes Adobe&#8217;s and other companies&#8217; plans to offer cross-compilers that would enable apps developed on platforms like Flash or .NET to run as native iPhone apps. Thinking further about this, Gruber concludes that [...]]]></description>
			<content:encoded><![CDATA[<p>John Gruber was the first to notice that <a href="http://daringfireball.net/2010/04/iphone_agreement_bans_flash_compiler">Apple has apparently updated a crucial section of the iPhone Developer Agreement</a> that practically crushes Adobe&#8217;s and other companies&#8217; plans to offer cross-compilers that would enable apps developed on platforms like Flash or .NET to run as native iPhone apps. Thinking further about this, <a href="http://daringfireball.net/2010/04/why_apple_changed_section_331">Gruber concludes that this is generally a good thing</a>, not only for Apple but also for iPhone developers and users:</p>
<blockquote><p>I can see two arguments here. On the one side, this rule should be good for quality. Cross-platform software toolkits have never — ever — produced top-notch native apps for Apple platforms. Not for the classic Mac OS, not for Mac OS X, and not for iPhone OS. Such apps generally have been downright crummy. On the other hand, perhaps iPhone users will be missing out on good apps that would have been released if not for this rule, but won’t now. I don’t think iPhone OS users are going to miss the sort of apps these cross-platform toolkits produce, though.</p>
<p>My opinion is that iPhone users will be well-served by this rule. The App Store is not lacking for quantity of titles.</p>
<p>Consider, for one example, Amazon’s Kindle clients for iPhone OS and Mac OS X. The iPhone OS Kindle app is excellent, a worthy rival in terms of experience to Apple’s own iBooks. The Mac Kindle app is a turd that doesn’t look, feel, or behave like a real Mac app. The iPhone OS Kindle app is a native iPhone app, written in Cocoa Touch. The Mac Kindle app was produced using the cross-platform Qt toolkit.</p></blockquote>
<p>I disagree. And not because I think that a <a href="http://labs.adobe.com/technologies/flashcs5/appsfor_iphone/">Flash-to-iPhone cross-compiler</a> or <a href="http://monotouch.net/">MonoTouch</a> is great to have (I really couldn&#8217;t care less), but because of other languages and environments the iPhone platform could profit from in the future. For example, I&#8217;d love to use Ruby both for iPhone development and even more as a dynamic language <em>on</em> the iPhone. <a href="http://twitter.com/dhh/status/11863765125">To say it with David Heinemeier Hansson</a>:</p>
<p><a href="http://twitter.com/dhh/status/11863765125"><img class="alignnone size-full wp-image-499" title="dhh's Tweet on Apple's new rules in the iPhone developer agreement" src="http://oleb.net/wordpress/wp-content/media/dhh-tweet-apple-iphone-developer-agreement.png" alt="Being an asshole just because you can is not a sign of strength but of weakness. (re: Apple's new restriction on programming languages)" width="617" height="340" /></a></p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/t51zBfLhJXA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/apple-bans-cross-compilers-for-iphone-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/apple-bans-cross-compilers-for-iphone-development/</feedburner:origLink></item>
		<item>
		<title>Steve Jobs: “Think of the children”</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/Vcbsdp-UIe0/</link>
		<comments>http://oleb.net/blog/2010/04/steve-jobs-think-of-the-children/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 08:47:11 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=490</guid>
		<description><![CDATA[Jeff LaMarche on Apple&#8217;s iPhone OS 4.0 event: I thought some of the answers given during the Q&#38;A period were just outright disingenuous. The most blatant case in point was when Steve was asked about distributing apps without the App Store, His response was to point out that Android has a &#8220;porn app store that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://iphonedevelopment.blogspot.com/2010/04/iphone-sdk-40.html">Jeff LaMarche on Apple&#8217;s iPhone OS 4.0 event</a>:</p>
<blockquote><p>I thought some of the answers given during the Q&amp;A period were just outright disingenuous. The most blatant case in point was when Steve was asked about distributing apps without the App Store, His response was to point out that Android has a &#8220;porn app store that your kids can get to&#8221;, and then state that Apple &#8220;didn&#8217;t want to go there&#8221;. Whisky. Tango. Foxtrot?</p>
<p>Kids can get to any number of porn web sites on a Mac, iPad or iPhone.</p>
<p>Apple does absolutely have a right to do this: It&#8217;s their walled garden. I just wish they&#8217;d be more upfront about their reasons when asked rather than giving stupid responses like &#8220;think of the children&#8221; (which has already become a bit of a joke from its use in censorship discussions). [...]</p>
<p>If Steve had stood up on stage and said &#8220;we want our 30% cut, so that&#8217;s why you can&#8217;t distribute outside the App Store&#8221;, it would have felt like it was an honest answer. If he had said &#8220;we want to control the experience in any way we can&#8221;, I would have bought it. I might not have liked it, but those would have felt like honest answers.</p>
<p>The answer we got today felt like a big &#8220;fuck you&#8221; disguised as a smarmy &#8220;we know better than you&#8221;.</p>
</blockquote>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/Vcbsdp-UIe0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/steve-jobs-think-of-the-children/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/steve-jobs-think-of-the-children/</feedburner:origLink></item>
		<item>
		<title>Universal App != Universal Binary</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/ecJByZ3wlxk/</link>
		<comments>http://oleb.net/blog/2010/04/universal-app-is-not-a-universal-binary/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 13:15:48 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=462</guid>
		<description><![CDATA[When Apple started talking about building universal apps that run on both iPhone and iPad, I immediately thought of the universal binaries that were the cornerstone of the PowerPC to Intel transition. I just assumed that a universal iPhone and iPad app was technically just the same as a universal binary when in fact, this [...]]]></description>
			<content:encoded><![CDATA[<p>When Apple started talking about building <a href="http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/StartingYourProject/StartingYourProject.html#//apple_ref/doc/uid/TP40009370-CH9-SW2">universal apps</a> that run on both iPhone and iPad, I immediately thought of the <a href="http://www.apple.com/universal/">universal binaries</a> that were the cornerstone of the PowerPC to Intel transition. I just assumed that a universal iPhone and iPad app was technically just the same as a universal binary when in fact, this is not true.</p>
<p>While the PowerPC and Intel platforms are totally different and incompatible architectures, the iPhone and iPad are both based on the ARM architecture. That means that, unlike a universal PowerPC/Intel binary, a universal app in the iPhone OS sense does not need to consist of two separate binaries. After all, all devices can run the same code. And this is exactly what Apple is doing. A universal app is just a &#8220;normal&#8221; iPhone OS app with some special keys in its <code>Info.plist</code>.</p>
<p>The consequence of this for developers is that, because both versions run the same binary, you cannot use conditional compilation directives (<code>#if ... #else ... #endif</code>) to generate different code for iPhone and iPad. All device-type-dependent branching must happen at runtime. <a href="http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/StartingYourProject/StartingYourProject.html#//apple_ref/doc/uid/TP40009370-CH9-SW11">Apple recommends we use the new <code>UI_USER_INTERFACE_IDIOM()</code> macro for this</a>:</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>UI_USER_INTERFACE_IDIOM<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">==</span> UIUserInterfaceIdiomPad<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// The device is an iPad running iPhone 3.2 or later.</span>
<span style="color: #002200;">&#125;</span>
<span style="color: #a61390;">else</span>
<span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// The device is an iPhone or iPod touch.</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>And this works great. You set your project&#8217;s Base SDK to iPhone OS 3.2 and the Deployment Target to 3.0 or 3.1 and you can build and run this code for an iPad device or the iPad simulator (running 3.2) or an iPhone device (running 3.0/3.1). Caveat: you can no longer test the iPhone version of your app in the Simulator. The reason for this is that the 3.2 Simulator always defaults to iPad mode if a universal application is run. And you cannot build your app for the 3.1 Simulator anymore because the 3.1 SDK does not know the <code>UI_USER_INTERFACE_IDIOM</code> symbol.</p>
<p>To remedy this, we need to use a conditional compilation block. <a href="http://iphonedevelopment.blogspot.com/2010/04/few-more-notes-on-creating-universal.html">Jeff LaMarche wrote about this approach</a> a few days ago and I am reposting his solution here with a small change because I think there&#8217;s a bug in his code (<a href="http://iphonedevelopment.blogspot.com/2010/04/few-more-notes-on-creating-universal.html?showComment=1270580224919#c7696767908654355678">see my comment on his post</a>):</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#if __IPHONE_OS_VERSION_MAX_ALLOWED &gt;= 30200</span>
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>UI_USER_INTERFACE_IDIOM<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">==</span> UIUserInterfaceIdiomPad<span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        <span style="color: #11740a; font-style: italic;">// The device is an iPad running iPhone 3.2 or later.</span>
    <span style="color: #002200;">&#125;</span>
    <span style="color: #a61390;">else</span>
<span style="color: #6e371a;">#endif</span>
    <span style="color: #002200;">&#123;</span>
        <span style="color: #11740a; font-style: italic;">// The device is an iPhone or iPod touch.</span>
    <span style="color: #002200;">&#125;</span></pre></div></div>

<p><img class="size-full" src="http://oleb.net/wordpress/wp-content/media/picture-effects-iphone-simulator-3-1-screenshot.png" alt="Picture Effects running in the iPhone Simulator 3.1" width="193" height="372" /> <img class="size-full" title="Picture Effects running on the iPad Simulator 3.2" src="http://oleb.net/wordpress/wp-content/media/ipad-device-screenshot-4.jpg" alt="Picture Effects running on the iPad Simulator 3.2" width="484" height="372" /><br />
<em>My universal app Picture Effects running on the iPhone Simulator 3.1 and the iPad Simulator 3.2</em></p>
<p><strong>Update April 13, 2010:</strong> Jim Dovey has <a href="http://quatermain.tumblr.com/post/517122761/running-universal-ipad-iphone-apps-in-the-simulator">discovered another solution that does not require adding the conditional compilation directives</a>: build your app for the 3.2 Simulator SDK first, then switch your target to the 3.0 Simulator SDK, then run (don&#8217;t build).</p>
<p><strong>Update April 9, 2010:</strong> Chris has asked me in the comments to prepare a starting point for a universal app. Sure, no problem. <a title="View-based Universal App Template for Xcode 3.2.2" href="http://oleb.net/wordpress/wp-content/media/UniversalViewBasedApp.zip">UniversalViewBasedApp.zip</a> is a very simple app that runs on iPhone and iPad. It contains separate NIBs for iPhone and iPad, and both version run on the same view controller code. To understand how the system knows which NIB files to load on which platform, see the <code>NSMainNibFile</code> and <code>NSMainNibFile~ipad</code> keys in the <code>Info.plist</code>.</p>
<p>Here&#8217;s how I created the app:</p>
<ul>
<li>Create a standard view-based app for the iPhone using Xcode&#8217;s built-in project template.</li>
<li>Choose <code>Project &gt; Upgrade Target for iPad...</code> and select the option to create a Universal app.</li>
<li>Open MainViewController.xib in Interface Builder, choose <code>File &gt; Create iPad Version</code> and save the resulting NIB file as MainViewController-iPad.xib and add it to your project.</li>
<li>In MainWindow-iPad.xib, set MainViewController&#8217;s NIB name property to MainViewController-iPad.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/ecJByZ3wlxk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/universal-app-is-not-a-universal-binary/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/universal-app-is-not-a-universal-binary/</feedburner:origLink></item>
		<item>
		<title>What’s new in Xcode 3.2.2</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/9Xrkph6xfRU/</link>
		<comments>http://oleb.net/blog/2010/04/whats-new-in-xcode-3-2-2/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 15:04:15 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=445</guid>
		<description><![CDATA[After yesterday&#8217;s post about the changes in iPhone SDK 3.2, let&#8217;s have a look at what&#8217;s new in Xcode 3.2.2. Contrary to the minimal jump in the version number from 3.2 to 3.2.2, Apple has made some major improvements for iPhone/iPad developers. Support for iPad development and universal apps This is a given. After all, [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://oleb.net/blog/2010/04/whats-new-in-iphone-sdk-3-2/" title="What's new in iPhone SDK 3.2">yesterday&#8217;s post about the changes in iPhone SDK 3.2</a>, let&#8217;s have a look at what&#8217;s new in Xcode 3.2.2. Contrary to the minimal jump in the version number from 3.2 to 3.2.2, Apple has made some major improvements for iPhone/iPad developers.</p>
<h3>Support for iPad development and universal apps</h3>
<p>This is a given. After all, the iPad launch is the sole reason for the release. Xcode 3.2.2 includes new project templates for iPad apps and has a menu command (Project > Upgrade Current Target for iPad&#8230;) that helps you get the project settings setup correctly when you want to add iPad support to your existing iPhone project. The Upgrade command gives you two options:</p>
<ol>
<li>Upgrade your existing iPhone app to a universal application that runs on both iPhone and iPad. Customers buy such an app once and can install it on multiple devices. The code that runs on the iPhone and iPad is identical and device-dependent branching in your code happens at runtime.</li>
<li>Create a separate iPad target based on your existing iPhone target. Both targets will use much of the same codebase but in the end, you compile two separate apps. Customers who want to use both the iPhone and iPad-optimized apps have to buy both of them. Since you end up with different binaries, device-dependent branching in your code can be handled with conditional compilation directives.</li>
</ol>
<p>Apple has explained this process very well in the iPad Programming Guide so I&#8217;m not gonna go into more detail here. See <a href="http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/StartingYourProject/StartingYourProject.html#//apple_ref/doc/uid/TP40009370-CH9-SW2">Creating a Universal Application</a> or <a href="http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/StartingYourProject/StartingYourProject.html#//apple_ref/doc/uid/TP40009370-CH9-SW8">Using a Single Xcode Project to Build Two Applications</a>, respectively.</p>
<h3>Build and Archive</h3>
<p>The new Build > Build and Archive command builds your app as usual, creates an <code>.ipa</code> file (the zip archive of your app bundle you need to create to submit your app to iTunes Connect) and then archives the app bundle, the <code>.ipa</code> file and the associated <code>.dSYM</code> file (containing the debug symbols you need to debug crash logs) in a subfolder of <code>~/Library/MobileDevice/Archived Applications</code>. These archives also appear in the new Archived Applications view in the Organizer.</p>
<div id="attachment_448" class="wp-caption aligncenter" style="width: 638px"><img src="http://oleb.net/wordpress/wp-content/media/xcode-3-2-2-archived-applications-folder.png" alt="Xcode 3.2.2 Archived Applications folder" title="Xcode 3.2.2 Archived Applications folder" width="628" height="210" class="size-full wp-image-448" /><p class="wp-caption-text">An application build in the Finder as archived by Xcode 3.2.2</p></div>
<div id="attachment_451" class="wp-caption aligncenter" style="width: 638px"><img src="http://oleb.net/wordpress/wp-content/media/xcode-3-2-2-organizer-archived-applications-e1270566011490.png" alt="Archived Applications in the Xcode 3.2.2 Organizer" title="Archived Applications in the Xcode 3.2.2 Organizer" width="628" height="448" class="size-full wp-image-451" /><p class="wp-caption-text">Archived Applications in the Xcode 3.2.2 Organizer</p></div>
<p>Unless you already have another automated method in place to archive your distribution builds (such as a custom build script), I encourage you to use Build and Archive for all Distribution builds, both for Ad Hoc and App Store distribution. That way, you won&#8217;t have to manually copy the all-important <code>.dSYM</code> file to a safe location and it also saves you the hassle of manually creating the <code>.ipa</code> zip archive. Whenever you want to distribute an Ad Hoc build to your beta testers, just set your build config Distribution, choose Build and Archive, and you&#8217;re done.</p>
<h3>iTunes Connect integration: Build validation and uploading</h3>
<p>The Organizer now also helps you with the next logical step after you have created a distribution build: sharing your Ad Hoc app with beta testers or uploading the final version to iTunes Connect. Take another look at the screenshot of the Organizer window above and note the three buttons at the bottom:</p>
<ul>
<li>Share Application lets you sign the build with an Ad Hoc distribution certificate and then save the signed <code>.ipa</code> file to disk or put it directly into an e-mail for distribution to your beta testers. Very handy.</li>
<li>Validate Application will, in <a href="http://developer.apple.com/iphone/library/releasenotes/General/RN-iPhoneSDK-3_2/index.html#//apple_ref/doc/uid/TP40009477-CH1-SW16" title="iPhone SDK 3.2 Release Notes">Apple&#8217;s words</a>, &#8220;run all of the validation tests that will be run upon submission to the App Store so that you can fix any problems before submitting your app.&#8221; It&#8217;s not quite clear to me what exactly these tests consist of, but it will definitely give you an error message if you failed to include an icon in your app (or if it has the wrong size) or if your code signing identity does not match the app&#8217;s bundle identifier in iTunes Connect. When I first read about this feature, I was very excited because I figured that the tests also include Apple&#8217;s apparently automated testing for use of undocumented APIs, but now I doubt this is the case. Does anybody know more?</li>
<li>Finally, Submit Application to iTunes Connect will sign the app with your App Store code signing identity and upload the binary directly to Apple. Before you do this, you must have set up the application with all its metadata (screenshots, 512&#215;512 icon, keywords) in iTunes Connect (this also true for the Validate Application step). Make especially sure that all your keywords are correct because you cannot change them afterwards unless you reject the binary.</li>
</ul>
<h3>Transfer your iPhone developer identity to a new computer</h3>
<p>With all the certificates and provisioning profiles Apple requires iPhone developers to manage, it can be quite a hassle to reinstall everything correctly after switching to a fresh install of OS X. In Xcode 3.2.2, there is a new Developer Profile item in the Organizer window that allows you to export all your provisioning profiles and code signing certificates into a single file which you can then import on a new computer with a single click.</p>
<div id="attachment_457" class="wp-caption aligncenter" style="width: 638px"><img src="http://oleb.net/wordpress/wp-content/media/xcode-3-2-2-organizer-developer-profile.png" alt="Developer Profile view in the Xcode 3.2.2 Organizer" title="Developer Profile view in the Xcode 3.2.2 Organizer" width="628" height="504" class="size-full wp-image-457" /><p class="wp-caption-text">Developer Profile view in the Xcode 3.2.2 Organizer</p></div>
<h3>Redesigned documentation</h3>
<p>Finally, the 3.2 API documentation has gotten a new look. I quite like the design. Functionality-wise, the help system seems to be unchanged.</p>
<div id="attachment_459" class="wp-caption aligncenter" style="width: 637px"><img src="http://oleb.net/wordpress/wp-content/media/xcode-3-2-2-documentation-e1270566097432.png" alt="Xcode 3.2.2 API Documentation view" title="Xcode 3.2.2 API Documentation view" width="627" height="477" class="size-full wp-image-459" /><p class="wp-caption-text">Xcode 3.2.2 API Documentation view</p></div>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/9Xrkph6xfRU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/whats-new-in-xcode-3-2-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/whats-new-in-xcode-3-2-2/</feedburner:origLink></item>
		<item>
		<title>What’s new in iPhone SDK 3.2</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/19Q0ZiUPXf8/</link>
		<comments>http://oleb.net/blog/2010/04/whats-new-in-iphone-sdk-3-2/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 22:53:48 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=441</guid>
		<description><![CDATA[Now that the final version of the iPad SDK is available and the NDA is lifted, let&#8217;s have a look at what is new. I will give an overview of the new features in this post and elaborate on some of them in more detail in the coming days. It&#8217;s called iPhone SDK 3.2, but [...]]]></description>
			<content:encoded><![CDATA[<p>Now that the <a href="http://developer.apple.com/iphone/">final version of the iPad SDK</a> is available and the NDA is lifted, let&#8217;s have a look at <a href="http://developer.apple.com/iphone/library/releasenotes/General/WhatsNewIniPhoneOS/Articles/iPhoneOS3_2.html#//apple_ref/doc/uid/TP40009337-SW1">what is new</a>. I will give an overview of the new features in this post and elaborate on some of them in more detail in the coming days.</p>
<h3>It&#8217;s called iPhone SDK 3.2, but it&#8217;s not for the iPhone</h3>
<p>When Apple released the first beta version of the iPhone SDK 3.2 after the iPad announcement in January 2010, nobody was surprised that it only supported iPad development at the time. However, many (including me) expected the new features to come to the iPhone as well once the final version arrived. Turns out this isn&#8217;t so and we will have to wait at least until the next SDK version (4.0 in the summer?) for a unified release. And while certainly not all of the new UI features for the iPad would make sense on the iPhone, the 3.2 SDK includes many changes that I&#8217;d love to have on the iPhone, too (CALayer drop shadows anyone?).</p>
<p>Now let&#8217;s start with the overview of the new features:</p>
<h3>New iPad-specific user interface elements</h3>
<p>Apple has introduced two fundamentally new UI paradigms that make use of the iPad&#8217;s larger screen: popovers and split views. Both of them will possibly never make their way to the iPhone because they simply make no sense on the iPhone&#8217;s small screen.</p>
<ul>
<li><strong>Popovers</strong> will be ubiquitous in many iPad apps. You often use them where you would go with modal view controllers or deep navigation controller hierarchies on the iPhone. Popovers are managed by the new <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIPopoverController_class/Reference/Reference.html"><code>UIPopoverController</code></a> class.</li>
<li><strong>Split views</strong> allow you to display a master-detail hierarchy side by side on one screen as opposed to the multiple-screen hierarchies managed by <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html"><code>UINavigationController</code></a> on the iPhone. The new <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UISplitViewController_class/Reference/Reference.html"><code>UISplitViewController</code></a> takes two of your view controllers and helps you manage their master-detail relationship.</li>
<li>In addition to the new UI paradigms, modal view controllers on the iPad can not only be presented in full screen, but also as <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UIModalPresentationPageSheet"><em>page sheets</em></a> (full screen in portrait but only portrait width in landscape orientation) and <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/c_ref/UIModalPresentationFormSheet"><em>form sheets</em></a> (centered on screen but smaller than full screen; more like oversized alert views). This is all to reduce full-screen transitions to a minimum, which would be irritating to users on the large iPad screen.</li>
</ul>
<h3>Major non-iPad-related new features</h3>
<p>The following features could in principle also work great on the iPhone and I hope that all or most of them make it to the small screen in the next SDK.</p>
<ul>
<li><strong>Gesture recognizers</strong> will finally liberate us from the tedious and error-prone work of trying to reimplement common gestures like swipes and pinches in our own custom views. Never was it easier to write a custom scroll view that only responds to two-finger swipes. This is one of my favorite features in the new SDK. <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIGestureRecognizer_Class/Reference/Reference.html"><code>UIGestureRecognizer</code></a> FTW!</li>
<li><strong>Custom input views</strong> means that you are not limited to the system-provided keyboard layouts anymore for data entry. You can provide completely custom-made input interfaces and make any view or control able to interact with them. That still means a lot of work if all you want is to replace one button on the system keyboard (because you would have to reimplement the whole thing) but it&#8217;s great for custom data entry interfaces as Apple demonstrates in their Numbers app.</li>
<li><strong>Core Text and more (with limitations)</strong>
<ul>
<li>The rendering of rich text with different fonts and formatting is quite hard in the iPhone SDK 3.1, and supporting not only <em>rendering</em> but also rich text <em>editing</em> is an almost impossible task. You would basically have to reinvent everything. The new SDK makes this a whole lot easier with its support for <a href="http://developer.apple.com/iphone/library/documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html">Core Text</a>, Apple&#8217;s C-based rich text rendering and layouting framework.</li>
<li>Still missing, though, is an enhanced <code>UITextView</code> that actually made use of the new capabilities. So if you want to write a Pages competitor, you get the rendering engine (almost) for free but you still have to write the rich text editor. The difference is that Apple makes this possible now, though not exactly easy. Implementing the massive <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITextInput_Protocol/Reference/Reference.html"><code>UITextInput</code></a> protocol is quite a lot of work. I haven&#8217;t seen an iPad app on the App Store that has pulled this off yet.</li>
<li><a href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CATextLayer_class/Introduction/Introduction.html"><code>CATextLayer</code></a> lets us easily render rich text on a Core Animation layer.</li>
<li>We can now include custom fonts in our app bundles and use them just like the system-provided fonts. Yay! Register your fonts with the system by including the <a href="http://developer.apple.com/iphone/library/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW18"><code>UIAppFonts</code></a> key in your <code>Info.plist</code>.</li>
<li><a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITextChecker_Class/Reference/Reference.html"><code>UITextChecker</code></a> is a new class that provides us with a spell checker.</li>
<li><code>NSString</code> got regular expression support in its search methods (<a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/rangeOfString:options:"><code>rangeOfString:options:</code></a> et al.).</li>
</ul>
</li>
<li><strong>File sharing support</strong> I still haven&#8217;t figured out how well this works in practice. Basically, all you need to do is add a <a href="http://developer.apple.com/iphone/library/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW20"><code>UIFileSharingEnabled</code></a> key to your <code>Info.plist</code> and then your app will be able to share its documents with its host computer via iTunes. Still sounds awfully complicated to me. Instead of relying on iTunes, Apple should mount an app&#8217;s Documents folder on the host computer directly. And not just when the USB cable is plugged in but also when both are on the same WiFi network.</li>
<li><strong>Register supported file types</strong> Your app can now tell the system which file types it supports (again via <code>Info.plist</code>) and receive notifications when a file of this type needs to be opened. This is used by apps like Mail that should be able to send arbitrary files they downloaded to the right application to open them. If your app needs to handle files of unknown types, you can use a <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html#//apple_ref/occ/cl/UIDocumentInteractionController"><code>UIDocumentInteractionController</code></a> to display those files to the user and let them preview and open them. This is a much-needed step to facilitate interaction between apps on the iPhone OS platform.</li>
<li><strong>External display support</strong> The built-for-Keynote feature. If an external display is connected to the iPad, the <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIScreen_Class/Reference/UIScreen.html"><code>UIScreen</code></a> class will return more than one screen and your app can create multiple <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html"><code>UIWindow</code></a> instances and assign each one to a specific screen.</li>
<li><strong>UIMenuController</strong> allows you to create custom popover menus like those that are used for the Copy &amp; Paste functions since OS 3.0. I hope this will make it to the iPhone, too. Until then, Oliver Drobnik has written a replacement called <a href="http://www.drobnik.com/touch/parts-store/">DTMenuController</a> (not free, though).</li>
</ul>
<h3>Smaller enhancements</h3>
<ul>
<li><strong>PDF generation</strong> UIKit includes new functions for generating PDF files in your application: <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIGraphicsBeginPDFContextToFile"><code>UIGraphicsBeginPDFContextToFile</code></a>, <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIGraphicsBeginPDFContextToData"><code>UIGraphicsBeginPDFContextToData</code></a>, <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIGraphicsBeginPDFPage"><code>UIGraphicsBeginPDFPage</code></a>, <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIGraphicsBeginPDFPageWithInfo"><code>UIGraphicsBeginPDFPageWithInfo</code></a>, and <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIGraphicsEndPDFContext"><code>UIGraphicsEndPDFContext</code></a>.</li>
<li>This is cool: <strong><code>CALayer</code> supports drop shadows</strong> with these new properties: <a href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/shadowOpacity"><code>shadowOpacity</code></a>, <a href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/shadowRadius"><code>shadowRadius</code></a>, <a href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/shadowOffset"><code>shadowOffset</code></a>, <a href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/shadowColor"><code>shadowColor</code></a>, and <a href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/shadowPath"><code>shadowPath</code></a>.</li>
<li>Videos played with <a href="http://developer.apple.com/iphone/library/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html"><code>MPMoviePlayerController</code></a> can now be displayed in arbitrary views and not just full screen. For the old full-screen behavior, use <a href="http://developer.apple.com/iphone/library/documentation/MediaPlayer/Reference/MPMoviePlayerViewController_class/Reference/Reference.html#//apple_ref/occ/cl/MPMoviePlayerViewController"><code>MPMoviePlayerViewController</code></a>.</li>
<li><a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html"><code>UIBezierPath</code></a> is an object-oriented wrapper for <code>CGPathRef</code>.</li>
<li>MapKit&#8217;s reverse geocoder now provides us with a <a href="http://developer.apple.com/iphone/library/documentation/MapKit/Reference/MKReverseGeocoder_Class/Reference/Reference.html#//apple_ref/occ/instp/MKReverseGeocoder/placemark"><code>placemark</code></a> property to access the results of the reverse geocoding process after they have been reported to the delegate.</li>
<li><code>UIScrollViewDelegate</code> got two new methods: <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIScrollViewDelegate_Protocol/Reference/UIScrollViewDelegate.html#//apple_ref/occ/intfm/UIScrollViewDelegate/scrollViewWillBeginZooming:withView:"><code>scrollViewWillBeginZooming:withView:</code></a> and <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIScrollViewDelegate_Protocol/Reference/UIScrollViewDelegate.html#//apple_ref/occ/intfm/UIScrollViewDelegate/scrollViewDidZoom:"><code>scrollViewDidZoom:</code></a>.</li>
</ul>
<h3>Next steps</h3>
<p>That&#8217;s it for the overview. You can still find a few more changes in the <a href="http://developer.apple.com/iphone/library/releasenotes/General/iPhone32APIDiffs/index.html#//apple_ref/doc/uid/TP40009405">iPhone OS 3.2 API Diffs</a>. In the next post, I will document <a href="http://oleb.net/blog/2010/04/whats-new-in-xcode-3-2-2/">what changed in Xcode 3.2.2</a>, and after that, I will pick out some of the new features and talk about them in more detail.</p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/19Q0ZiUPXf8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/whats-new-in-iphone-sdk-3-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/whats-new-in-iphone-sdk-3-2/</feedburner:origLink></item>
		<item>
		<title>Video: Picture Effects for iPad</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/4xNcSleKDEY/</link>
		<comments>http://oleb.net/blog/2010/04/video-picture-effects-for-ipad/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 10:32:16 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=435</guid>
		<description><![CDATA[A quick demo of the realtime editing in Picture Effects: Picture Effects demo on YouTube.]]></description>
			<content:encoded><![CDATA[<p>A quick demo of the realtime editing in <a href="http://pictureeffectsapp.com">Picture Effects</a>:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="505" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/zhBrgvCPnTc&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="505" src="http://www.youtube.com/v/zhBrgvCPnTc&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://www.youtube.com/watch?v=zhBrgvCPnTc">Picture Effects demo on YouTube</a>.</p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/4xNcSleKDEY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/video-picture-effects-for-ipad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/video-picture-effects-for-ipad/</feedburner:origLink></item>
		<item>
		<title>Announcing Picture Effects for iPad and iPhone</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/52DS-cS9ZkU/</link>
		<comments>http://oleb.net/blog/2010/04/announcing-picture-effects-for-ipad-and-iphone/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 10:27:39 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=415</guid>
		<description><![CDATA[My new app, Picture Effects, is now available on the App Store. It is a fun photo editor inspired by Apple&#8217;s Photo Booth on the Mac. You can distort your photos with some awesome effects like Twirl, Squeeze, Fisheye, etc. And all editing is done in realtime by dragging and pinching across the picture. I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://pictureeffectsapp.com"><img class="alignleft size-full wp-image-416" style="margin-left: 10px; margin-right: 10px;" title="Picture Effects Icon" src="http://oleb.net/wordpress/wp-content/media/picture-effects-icon-round-140x140.png" alt="" width="140" height="140" /></a>My new app, <a href="http://pictureeffectsapp.com">Picture Effects</a>, is now available on the App Store. It is a fun photo editor inspired by Apple&#8217;s Photo Booth on the Mac. You can distort your photos with some awesome effects like Twirl, Squeeze, Fisheye, etc. And all editing is done in realtime by dragging and pinching across the picture. I am really happy how it turned out. You can buy <a href="http://itunes.apple.com/us/app/picture-effects/id362066808?mt=8">Picture Effects on the App Store</a> for $2.99.</p>
<p>While this app started out as an iPhone-only project, I have used the last couple of weeks to design a special iPad version and make it a universal app that looks great on both devices. Porting the project to the iPad went quite smoothly. Apple really has done a good job with the new iPhone SDK and the documentation. I am going to write a separate article about my learnings later.</p>
<p>Picture Effects was also my first project that involved OpenGL. To achieve the necessary performance for the realtime manipulation of the photos, I implemented the distortion filters as Open GL <a href="http://en.wikipedia.org/wiki/Fragment_shader">fragment shaders</a>. And while it was surprisingly simple (after I had found some inspiration on the net) to write the actual filter algorithms, the integration of OpenGL rendering with standard UIKit controls and the <a title="Model-view-controller" href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">MVC pattern</a> posed some problems on its own that also deserve a separate article in the future.</p>
<h3>Screenshots</h3>
<p>Here are a few screenshots of Picture Effects on both the iPhone and iPad:</p>
<p><img class="size-medium wp-image-428 alignnone" title="Picture Effects on the iPhone 1" src="http://oleb.net/wordpress/wp-content/media/pictureeffects-iphone-screenshot-1-213x320.png" alt="Screenshot 1 of Picture Effects on the iPhone" width="213" height="320" /> <img class="size-medium wp-image-427" title="Picture Effects on the iPhone 2" src="http://oleb.net/wordpress/wp-content/media/pictureeffects-iphone-screenshot-2-213x320.png" alt="Screenshot 2 of Picture Effects on the iPhone" width="213" height="320" /> <img class="size-medium wp-image-429" title="Picture Effects on the iPhone 3" src="http://oleb.net/wordpress/wp-content/media/pictureeffects-iphone-screenshot-3-213x320.png" alt="Screenshot 3 of Picture Effects on the iPhone" width="213" height="320" /></p>
<p><img class="size-full wp-image-426 alignnone" title="Picture Effects on the iPad" src="http://oleb.net/wordpress/wp-content/media/pictureeffects-ipad-device-screenshot-5.jpg" alt="Screenshot of Picture Effects on the iPad" width="620" height="477" /></p>
<p>If you decide to try Picture Effects, I&#8217;d be very interested in your feedback.</p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/52DS-cS9ZkU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/04/announcing-picture-effects-for-ipad-and-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/04/announcing-picture-effects-for-ipad-and-iphone/</feedburner:origLink></item>
		<item>
		<title>If you want to learn Cocoa…</title>
		<link>http://feedproxy.google.com/~r/ole-begemann-dev-blog/~3/yKSQORYDnE4/</link>
		<comments>http://oleb.net/blog/2010/03/if-you-want-to-learn-cocoa/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 14:59:58 +0000</pubDate>
		<dc:creator>Ole Begemann</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://oleb.net/?p=392</guid>
		<description><![CDATA[&#8230;be prepared to write a lot more code than in your typical &#8220;scripting&#8221; language. Three examples (I am using Ruby for comparison because it is the scripting language I am most familiar with; things would look very much the same with Python or PHP): 1. Declare a small hash/dictionary of key-value pairs Ruby: person = [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230;be prepared to write a lot more code than in your typical &#8220;scripting&#8221; language. Three examples (I am using Ruby for comparison because it is the scripting language I am most familiar with; things would look very much the same with Python or PHP):</p>
<h3>1. Declare a small hash/dictionary of key-value pairs</h3>
<p><strong>Ruby:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">person = <span style="color:#006600; font-weight:bold;">&#123;</span> 
  <span style="color:#ff3333; font-weight:bold;">:name</span>           <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;John Appleseed&quot;</span>, 
  <span style="color:#ff3333; font-weight:bold;">:age</span>            <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">30</span>, 
  <span style="color:#ff3333; font-weight:bold;">:favorite_fruit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#996600;">&quot;apple&quot;</span>, <span style="color:#996600;">&quot;banana&quot;</span>, <span style="color:#996600;">&quot;kiwi&quot;</span> <span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p><strong>Cocoa:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>person <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span>
                        <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;John Appleseed&quot;</span>,               <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;name&quot;</span>,
                        <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInteger<span style="color: #002200;">:</span><span style="color: #2400d9;">30</span><span style="color: #002200;">&#93;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;age&quot;</span>,
                        <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;apple&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;banana&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;kiwi&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>,
                                                         <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;favoriteFruit&quot;</span>,
                        <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Now which of these is easier to read?</p>
<h3>2. What day of the month is today?</h3>
<p><strong>Ruby:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">today = <span style="color:#CC00FF; font-weight:bold;">Date</span>.<span style="color:#9900CC;">today</span>                       <span style="color:#008000; font-style:italic;"># =&gt; #&lt;Date: 4910525/2,0,2299161&gt;</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Day of the month: %d&quot;</span> <span style="color:#006600; font-weight:bold;">%</span> today.<span style="color:#9900CC;">day</span>  <span style="color:#008000; font-style:italic;"># =&gt; Day of the month: 7</span></pre></div></div>

<p><strong>Cocoa:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSDate</span> <span style="color: #002200;">*</span>today <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDate</span> date<span style="color: #002200;">&#93;</span>;                        <span style="color: #11740a; font-style: italic;">// =&gt; 2010-03-07 15:15:26 +0100</span>
<span style="color: #400080;">NSCalendar</span> <span style="color: #002200;">*</span>calendar <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSCalendar</span> currentCalendar<span style="color: #002200;">&#93;</span>;  <span style="color: #11740a; font-style: italic;">// =&gt; &lt;__NSCFCalendar: 0x100400160&gt;</span>
<span style="color: #400080;">NSDateComponents</span> <span style="color: #002200;">*</span>components <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>calendar components<span style="color: #002200;">:</span>NSDayCalendarUnit
                                           fromDate<span style="color: #002200;">:</span>today<span style="color: #002200;">&#93;</span>;
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Day of the month: %d&quot;</span>, <span style="color: #002200;">&#91;</span>components day<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;     <span style="color: #11740a; font-style: italic;">// =&gt; Day of the month: 7</span></pre></div></div>

<h3>3. Fetch something from the data store</h3>
<p><strong>Ruby on Rails (Active Record):</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">result = Person.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:first_name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;John&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#ff3333; font-weight:bold;">:order</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;created_at DESC&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p><strong>Cocoa (Core Data):</strong></p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSFetchRequest</span> <span style="color: #002200;">*</span>fetchRequest <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSFetchRequest</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #400080;">NSEntityDescription</span> <span style="color: #002200;">*</span>entity <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSEntityDescription</span> entityForName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Person&quot;</span> inManagedObjectContext<span style="color: #002200;">:</span>self.managedObjectContext<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>fetchRequest setEntity<span style="color: #002200;">:</span>entity<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #400080;">NSPredicate</span> <span style="color: #002200;">*</span>predicate <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSPredicate</span> predicateWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;firstName == %@&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;John&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>fetchRequest setPredicate<span style="color: #002200;">:</span>predicate<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #400080;">NSSortDescriptor</span> <span style="color: #002200;">*</span>sortDescriptor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSSortDescriptor</span> alloc<span style="color: #002200;">&#93;</span> initWithKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;creationDate&quot;</span> ascending<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>fetchRequest setSortDescriptors<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObject<span style="color: #002200;">:</span>sortDescriptor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>sortDescriptor release<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>fetchError <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>fetchResult <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self.managedObjectContext executeFetchRequest<span style="color: #002200;">:</span>fetchRequest error<span style="color: #002200;">:&amp;</span>error<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>fetchRequest release<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Now I know this is not a fair comparison, Objective-C/Cocoa has many advantages over Ruby et al., you can&#8217;t compare Core Data to Active Record, etc. Still, I find the differences very striking, especially regarding the readability of the code.</p>
<img src="http://feeds.feedburner.com/~r/ole-begemann-dev-blog/~4/yKSQORYDnE4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://oleb.net/blog/2010/03/if-you-want-to-learn-cocoa/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://oleb.net/blog/2010/03/if-you-want-to-learn-cocoa/</feedburner:origLink></item>
	</channel>
</rss>
