<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Peter Friese</title>
	
	<link>http://www.peterfriese.de</link>
	<description>Software Architect / Mobile Developer / Public Speaker</description>
	<lastBuildDate>Thu, 21 Mar 2013 22:57:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/FormFollowsFunction" /><feedburner:info uri="formfollowsfunction" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>FormFollowsFunction</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Do Androids Dream of Electric Sheep?</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/8ZCxfEJFDf0/</link>
		<comments>http://www.peterfriese.de/do-androids-dream-of-electric-sheep/#comments</comments>
		<pubDate>Thu, 21 Mar 2013 22:33:48 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Talks]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=974</guid>
		<description><![CDATA[Humans have always been fascinated by the idea of talking with machines. Almost no main stream science fiction movie exists that does not pick up the idea of audio-visual communication with computers, the most well-known probably being 2001 &#8211; A Space Odyssey, Blade Runner, Star Trek, The Hitchhiker’s Guide to the Galaxy and I, Robot. [...]]]></description>
			<content:encoded><![CDATA[<p>Humans have always been fascinated by the idea of talking with machines. Almost no main stream science fiction movie exists that does not pick up the idea of audio-visual communication with computers, the most well-known probably being <em>2001 &#8211; A Space Odyssey</em>, <em>Blade Runner</em>, <em>Star Trek</em>, <em>The Hitchhiker’s Guide to the Galaxy</em> and <em>I, Robot</em>.</p>
<p><span id="more-974"></span></p>
<p>In all of these movies, humans can directly communicate with computers using voice commands (“Tea. Earl Grey, hot”) or more elaborate sentences and the computers will talk back to humans as a result. In some of the movies, the computer is a non-bodily entity (like the ship’s main computer in Star Trek), but sometimes it even is humanoid (like Cmdr. Data in <em>Star Trek</em> or the Replicants in <em>Blade Runner</em>).</p>
<p>In a Pecha Kucha presentation I recently delivered at the OOP conference in Munich, I took on this theme and started my talk with a imaginative conversation between two computer programs that most of you might know very well: Eliza and Siri.</p>
<p><iframe src="http://player.vimeo.com/video/61467056" frameborder="0" width="500" height="202"></iframe></p>
<p><a href="http://vimeo.com/61467056">Do Androids Dream of Electric Sheep?</a> from <a href="http://vimeo.com/peterfriese">Peter Friese</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>In this Pecha Kucha session, Siri and Eliza join me live on stage to explain why we do not (yet) use the potential of our smart phones.</p>
<p>Much has been said about Siri, so let’s focus on Eliza.</p>
<p>Eliza started as an experiment in 1964, when Joseph Weizenbaum, then professor of computer sciences at the MIT, wrote it as an early attempt to research natural language communication between man and computer (see his ACM paper “ELIZA &#8211; A Computer Program For the Study of Natural Language Communication Between Man And Machine”). At its heart, Eliza is program that reacts to specific key words in sentences entered by a human user and will then respond to those keywords according to a predefined script. It’s the script that basically makes up the “personality” of Eliza, the most famous one being <em>Doctor</em>, simulating a rogerian psychoanalyst.</p>
<p>(Weizenbaum was rather surprised to see how people thought that Eliza had a real personality and a capacity for empathy. In reaction, he started to raise uncomfortable questions about our dependence on computers.)</p>
<p>In my Pecha Kucha, I went on to tell my audience to make better use of the capabilities of our smart phones. Most people have stopped thinking about it, but after all, we’re carrying a super computer in our pockets.</p>
<p>So to set a good example, I decided to create <a title="ElizaApp" href="http://elizaapp.com" target="_blank">ElizaApp</a> &#8211; an app that can listen to what you say and answer in spoken language. This is going to be a great project, because I’ll show several very interesting things:</p>
<ol>
<li>How to analyse spoken language on a mobile device</li>
<li>How to synthesize speech on mobile devices</li>
<li>How to integrate a JavaScript engine in your mobile app</li>
<li>How to create a Siri-look-alike chat UI</li>
</ol>
<p>Over the course of the next few weeks, I will write several posts covering these topics. If there is anything that interests you in particular, feel free to add a comment.</p>
<p>Of course, in the end Eliza will be available on the App Store. In the mean time, be sure to check out <a title="ElizaApp" href="http://elizaapp.com" target="_blank">ElizaApp</a> and register for early access!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=8ZCxfEJFDf0:4W0m1Jhp34M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=8ZCxfEJFDf0:4W0m1Jhp34M:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=8ZCxfEJFDf0:4W0m1Jhp34M:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=8ZCxfEJFDf0:4W0m1Jhp34M:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=8ZCxfEJFDf0:4W0m1Jhp34M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=8ZCxfEJFDf0:4W0m1Jhp34M:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=8ZCxfEJFDf0:4W0m1Jhp34M:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=8ZCxfEJFDf0:4W0m1Jhp34M:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=8ZCxfEJFDf0:4W0m1Jhp34M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=8ZCxfEJFDf0:4W0m1Jhp34M:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=8ZCxfEJFDf0:4W0m1Jhp34M:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=8ZCxfEJFDf0:4W0m1Jhp34M:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/8ZCxfEJFDf0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/do-androids-dream-of-electric-sheep/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/do-androids-dream-of-electric-sheep/</feedburner:origLink></item>
		<item>
		<title>Writing Xtext Scope Providers with Xtend</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/AAVut_UtGQQ/</link>
		<comments>http://www.peterfriese.de/writing-xtext-scope-providers-with-xtend/#comments</comments>
		<pubDate>Tue, 14 Aug 2012 20:04:55 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[DSLs]]></category>
		<category><![CDATA[Xtext]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=922</guid>
		<description><![CDATA[Scope is an important concept in the design of programming languages. In Xtext, scoping is used to drive two major parts of your DSL: linking and content assist. While Xtext applies the 80/20 rule very successfully, thereby providing you with a decent scoping implementation out of the box, eventually you&#8217;ll have to roll up your [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Scope_(computer_science)">Scope</a> is an <a href="http://phobos.ramapo.edu/~amruth/grants/problets/courseware/scope/home.html">important concept</a> in the design of programming languages. In Xtext, scoping is used <a href="http://zarnekow.blogspot.de/2009/01/xtext-corner-2-linking-and-scoping.html">to drive two major parts</a> of your DSL: <a href="http://www.eclipse.org/Xtext/documentation.html#linking">linking</a> and <a href="http://www.eclipse.org/Xtext/documentation.html#contentAssist">content assist</a>. While Xtext applies the <a href="http://en.wikiquote.org/wiki/Alan_Kay">80/20 rule</a> very successfully, thereby providing you with a decent scoping implementation out of the box, eventually you&#8217;ll have to roll up your sleeves and write your own scope provider.</p>
<p><span id="more-922"></span></p>
<p>Over the years, implementing scope providers has become significantly easier, much thanks to the tiny internal scoping DSL provided by <code>org.eclipse.xtext.scoping.Scopes</code> (<a href="https://github.com/eclipse/xtext/blob/v2.3.0/plugins/org.eclipse.xtext/src/org/eclipse/xtext/scoping/Scopes.java">src</a>). However, collecting the elements that make up a scope can be a very cumbersome task if you have to use Java. Let’s face it &#8211; <a href="http://www.cafeaulait.org/slides/hope/02.html">Java has not been built for traversing models.</a></p>
<p>A language much better suited to traversing models is <a href="http://www.eclipse.org/xtend/">Xtend</a>, the newest kid on the X block. If you didn’t yet give it a try, you should do so now &#8211; even if you’re not writing an Xtext DSL. Xtend directly translates to Java code and allows you to write very concise code by eliminating much of Java’s ceremony. You can use it to write everything you’d write in Java &#8211; from <a href="http://blog.efftinge.de/2011/12/writing-android-uis-with-xtend.html">Android UIs</a> to <a href="http://www.eclipse.org/Xtext/7languagesDoc.html#httpRouting">web applications</a> &#8211; so why not write Eclipse plug-ins with Xtend?</p>
<p>To write the scope provider for your language using Xtend, you need to follow a few very simple steps:</p>
<ol>
<li>
<p>Disable generating the scope provider stub. Open <code>Generate&lt;YourDSL&gt;.mwe2</code> in the DSL project and find the line </p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">fragment <span style="color: #339933;">=</span> scoping.<span style="color: #006633;">ImportNamespacesScopingFragment</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
<li>
<p>Change this line to</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">fragment <span style="color: #339933;">=</span> scoping.<span style="color: #006633;">ImportNamespacesScopingFragment</span> <span style="color: #009900;">&#123;</span>
    generateStub <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
<li>
<p>If you already have a Java-based scope provider, copy the implementation to a safe place and delete the Java file to make room for the new Xtend-based scope provider.</p>
</li>
<li>
<p>Create a new Xtend class <code>&lt;YourDSLPackage&gt;.&lt;YourDSL&gt;ScopeProvider.xtend</code> in the DSL project. Make sure this class inherits from <code>org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider</code>.</p>
</li>
<li>
<p>Start writing your scope provider using Xtend.</p>
</li>
<li>
<p>Don’t forget to smile <img src='http://www.peterfriese.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
</li>
</ol>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=AAVut_UtGQQ:AIdWXnJzLkc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=AAVut_UtGQQ:AIdWXnJzLkc:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=AAVut_UtGQQ:AIdWXnJzLkc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=AAVut_UtGQQ:AIdWXnJzLkc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=AAVut_UtGQQ:AIdWXnJzLkc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=AAVut_UtGQQ:AIdWXnJzLkc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=AAVut_UtGQQ:AIdWXnJzLkc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=AAVut_UtGQQ:AIdWXnJzLkc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=AAVut_UtGQQ:AIdWXnJzLkc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=AAVut_UtGQQ:AIdWXnJzLkc:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=AAVut_UtGQQ:AIdWXnJzLkc:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=AAVut_UtGQQ:AIdWXnJzLkc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/AAVut_UtGQQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/writing-xtext-scope-providers-with-xtend/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/writing-xtext-scope-providers-with-xtend/</feedburner:origLink></item>
		<item>
		<title>Using CocoaPods to manage your dependencies</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/_McCGhIe3dE/</link>
		<comments>http://www.peterfriese.de/using-cocoapods-to-manage-your-dependencies/#comments</comments>
		<pubDate>Fri, 29 Jun 2012 20:42:22 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[cocoapods]]></category>
		<category><![CDATA[dependency management]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=913</guid>
		<description><![CDATA[One of the few things that I find really annoying about developing apps for the iOS platform is how cumbersome it is to include third party libraries in your projects. Depending on the complexity of the library (e.g. its respective dependencies and transitive dependencies) and the effort the authors put into the consumability of their [...]]]></description>
			<content:encoded><![CDATA[<p>One of the few things that I find really annoying about developing apps for the iOS platform is how cumbersome it is to include third party libraries in your projects. Depending on the complexity of the library (e.g. its respective dependencies and transitive dependencies) and the effort the authors put into the consumability of their library, the steps required to add a library to your project range from just copying a few files into your source folder to a whopping two-page description of drag&#8217;n&#8217;drop wizardry.<br />
<span id="more-913"></span><br />
Wouldn&#8217;t it be awesome if you could just specify a list of dependencies and be done? You might have heard of RubyGems, Maven, Ivy, NuGet or npm that bring dependency management to the worlds of Ruby, Java, .NET and JavaScript developers.</p>
<p>Well, it turns out there finally is a solution for us Cocoa developers &#8211; CocoaPods. Getting started with CocoaPods is really easy and once you started using it, you won&#8217;t look back again.</p>
<h2>Installation</h2>
<p>CocoaPods itself is distributed as a Ruby gem, so installing it is as simple as:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">sudo</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> cocoapods
pod setup</pre></td></tr></table></div>

<h2>Usage</h2>
<p>Using CocoaPods to manage your project&#8217;s dependencies is a two-step process:</p>
<ol>
<li>Specify the dependency in you project&#8217;s dependency specification file, <code>Podfile</code></li>
<li>Run <code>pod install</code></li>
</ol>
<p>Let me illustrate this by way of a simple example. Let&#8217;s assume you want to build an application with the awesome RestKit library. If you have used RestKit before, you know that adding it to your project is a rather involved process. Over the years, it has become significantly easier, but it still needs a very detailed installation instruction with lots of screenshots &#8211; check out their <a href="https://github.com/RestKit/RestKit/wiki/Installing-RestKit-in-Xcode-4.x">wiki page</a>.</p>
<p>With CocoaPods, all you need to do is this:</p>
<ol>
<li>Create a new empty project, naming it <code>RestEasyWithCocoaPods</code></li>
<li>In your project folder, create a new file, <code>Podfile</code></li>
<li>Fill in the following information:

<div class="wp_syntax"><table><tr><td class="code"><pre class="ruby" style="font-family:monospace;">platform <span style="color:#ff3333; font-weight:bold;">:ios</span>
dependency <span style="color:#996600;">'RestKit'</span>
dependency <span style="color:#996600;">'RestKit/UI'</span>
dependency <span style="color:#996600;">'RestKit/Network'</span>
dependency <span style="color:#996600;">'RestKit/ObjectMapping'</span>                       
dependency <span style="color:#996600;">'RestKit/ObjectMapping/CoreData'</span>
dependency <span style="color:#996600;">'RestKit/ObjectMapping/XML'</span>
dependency <span style="color:#996600;">'RestKit/ObjectMapping/JSON'</span></pre></td></tr></table></div>

</li>
<li>Run <code>pod install RestEasyWithCocoaPods.xcodeproj</code>. </li>
<li>Open the newly created workspace, <code>RestEasyWithCocoaPods.xcworkspace</code></li>
<li>Add the RestKit headers to <code>RestEasyWithCocoaPods-Prefix.pch</code>:

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#ifdef __OBJC__</span>
    <span style="color: #6e371a;">#import &lt;UIKit/UIKit.h&gt;</span>
    <span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span>
    <span style="color: #6e371a;">#import &lt;RestKit/RestKit.h&gt;</span>
<span style="color: #6e371a;">#endif</span></pre></td></tr></table></div>

</li>
<li>Done. Go and build awesome stuff with RestKit (more on this in another post).</li>
</ol>
<h2>Where to go from here</h2>
<p>Wasn&#8217;t that a lot easier than all the other ways to install third party libraries? </p>
<p>If you are curious which libraries are supported by CocoaPods, go to <a href="http://cocoapods.org">CocoaPods.org</a> &#8211; they have a nice little UI for searching their pod specification repository. If you are more include to using the command line, you are welcome to use <code>pod search &lt;yoursearchterm&gt;</code> to search for a specific library.</p>
<p>If your preferred library is not yet supported, why not help them out and build a pod spec? <a href="https://github.com/CocoaPods/CocoaPods">CocoaPods</a> itself and the <a href="https://github.com/CocoaPods/Specs">pod spec repository</a> are hosted on Github, so adding new pod specifications is really easy. The CocoaPods wiki has a section on <a href="https://github.com/CocoaPods/CocoaPods/wiki/The-podspec-format">creating</a> and <a href="https://github.com/CocoaPods/CocoaPods/wiki/Sharing-pod-specifications">publishing</a> new podspec files.</p>
<p>Now go and create awesome stuff!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=_McCGhIe3dE:axpBCo8Nky4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=_McCGhIe3dE:axpBCo8Nky4:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=_McCGhIe3dE:axpBCo8Nky4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=_McCGhIe3dE:axpBCo8Nky4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=_McCGhIe3dE:axpBCo8Nky4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=_McCGhIe3dE:axpBCo8Nky4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=_McCGhIe3dE:axpBCo8Nky4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=_McCGhIe3dE:axpBCo8Nky4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=_McCGhIe3dE:axpBCo8Nky4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=_McCGhIe3dE:axpBCo8Nky4:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=_McCGhIe3dE:axpBCo8Nky4:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=_McCGhIe3dE:axpBCo8Nky4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/_McCGhIe3dE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/using-cocoapods-to-manage-your-dependencies/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/using-cocoapods-to-manage-your-dependencies/</feedburner:origLink></item>
		<item>
		<title>The Accounts and Twitter Framework on iOS 5</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/sqDykV_1QMY/</link>
		<comments>http://www.peterfriese.de/the-accounts-and-twitter-framework-on-ios-5/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 21:30:46 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[ios5]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=850</guid>
		<description><![CDATA[Adding Twitter support is something that makes quite a lot of sense for a number of applications. If you&#8217;re in a news reader application you might want to let your followers know about an interesting article you just read. If you&#8217;re in a conference schedule app, you not only want to let your followers know [...]]]></description>
			<content:encoded><![CDATA[<p>Adding Twitter support is something that makes quite a lot of sense for a number of applications. If you&#8217;re in a news reader application you might want to let your followers know about an interesting article you just read. If you&#8217;re in a conference schedule app, you not only want to let your followers know about the awesome talks you&#8217;re listening to but you also might want to know which other talks other conference attendees are tweeting about to decide whether they are actually even more awesome than that talk you&#8217;re stuck in&#8230;<br />
<span id="more-850"></span><br />
Starting with iOS 5, Apple has introduced an <a href="http://developer.apple.com/library/ios/#documentation/Twitter/Reference/TwitterFrameworkReference/_index.html">official API for accessing Twitter from your iOS</a> applications. Before iOS 5, integrating Twitter in your apps was a rather cumbersome experience which required us developers to jump through many hoops.</p>
<p>In this post I want to outline the most important features of the iOS Twitter and Accounts APIs and explain how to use them to write a decent Twitter client for your next app in very few lines of code. The <a href="http://github.com/peterfriese/TwitterClient">full source code</a> is available on Github for your convenience.</p>
<p>The Accounts and Twitter frameworks perform much of the heavy lifting required when talking to Twitter, such as</p>
<ul>
<li>Providing a secure local storage for user accounts, including their credentials</li>
<li>Providing an easy way to sign API requests you send to Twitter. You no longer have to include code to handle <a href="https://dev.twitter.com/docs/auth/oauth/faq">OAuth</a> or <a href="https://dev.twitter.com/docs/oauth/xauth">xAuth</a> in your app &#8211; this has all been done by Apple for you</li>
<li>Providing a basic UI for composing tweets, including switching the user account you tweet from, uploading images in a tweet and including your current location</li>
</ul>
<p>Lots of free stuff, so let&#8217;s have a look at how much (or little) code we actually need to write to tap this source of awesomeness.</p>
<h2>Using the Accounts Framework to fetch the list of accounts</h2>
<p>The <a href="http://developer.apple.com/library/ios/#documentation/Accounts/Reference/AccountsFrameworkRef/_index.html">Accounts Framework</a> provides access to all Twitter accounts the user has added to their iPhone using the settings app. Currently, the Accounts Framework only supports Twitter accounts, but you&#8217;ll soon realize it has been build so that it basically can be used to access any other kind of account in future releases. Maybe the next version of iOS will easy access to Google+ and Facebook accounts &#8211;  we&#8217;ll see.</p>
<p>To use the Accounts and Twitter frameworks, we need to add them to the project:</p>
<div id="attachment_878" class="wp-caption aligncenter" style="width: 510px"><a class="lightbox"  title ="Add Accounts and Twitter frameworks to the project" href="http://www.peterfriese.de/wp-content/AddTwitterAccounts.png"><img src="http://www.peterfriese.de/wp-content/AddTwitterAccounts.png" alt="Add Accounts and Twitter frameworks to the project" title="Add Accounts and Twitter frameworks to the project" width="500" height="203" class="size-full wp-image-878" /></a><p class="wp-caption-text">Add Accounts and Twitter frameworks to the project</p></div>
<p>Once that&#8217;s done, we can use the Accounts framework to fetch the list of Twitter accounts on the device.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>fetchData
<span style="color: #002200;">&#123;</span>
  <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>_accounts <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>_accountStore <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
      self.accountStore <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>ACAccountStore alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
    ACAccountType <span style="color: #002200;">*</span>accountTypeTwitter <span style="color: #002200;">=</span> 
      <span style="color: #002200;">&#91;</span>self.accountStore
        accountTypeWithAccountTypeIdentifier<span style="color: #002200;">:</span>ACAccountTypeIdentifierTwitter<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>self.accountStore requestAccessToAccountsWithType<span style="color: #002200;">:</span>accountTypeTwitter
      withCompletionHandler<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span> granted, <span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>error<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
      <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>granted<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        dispatch_sync<span style="color: #002200;">&#40;</span>dispatch_get_main_queue<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>, <span style="color: #002200;">^</span><span style="color: #002200;">&#123;</span>
          self.accounts <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self.accountStore
            accountsWithAccountType<span style="color: #002200;">:</span>accountTypeTwitter<span style="color: #002200;">&#93;</span>;
          <span style="color: #002200;">&#91;</span>self.tableView reloadData<span style="color: #002200;">&#93;</span>; 
        <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;
      <span style="color: #002200;">&#125;</span>
    <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>As many other new APIs that perform potentially blocking I/O, the Accounts framework uses blocks to execute your code as soon as the data you requested is available. When querying the accounts database, we can specify the kind of accounts we&#8217;re interested in &#8211; <code>ACAccountTypeIdentifierTwitter</code> in our case. If we&#8217;re granted access to the accounts database, we fetch the list of accounts using <code>accountsWithAccountType:</code>. As soon as we&#8217;ve got this list, we want to save it in a ivar / property and update the UI. Since there is no guarantee we&#8217;re on the UI thread when our completion handler is run, we use <code>dispatch_sync</code> to ensure assigning the list of accounts and updating the UI is run on the UI thread (<code>dispatch_get_main_queue()</code> returns the GCD queue of the UI thread). For more information on blocks and Grand Central Dispatch (GCD) check out <a href="http://www.mikeash.com/pyblog/friday-qa-2009-08-28-intro-to-grand-central-dispatch-part-i-basics-and-dispatch-queues.html">this excellent blog post</a>. </p>
<p>Displaying the accounts in a <code>UITableViewController</code> is straightforward:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView
                          cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSIndexPath</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath
<span style="color: #002200;">&#123;</span>
  <span style="color: #a61390;">static</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>CellIdent <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cell&quot;</span>;
&nbsp;
  UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>CellIdent<span style="color: #002200;">&#93;</span>;
  <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>cell <span style="color: #002200;">==</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UITableViewCell alloc<span style="color: #002200;">&#93;</span> 
      initWithStyle<span style="color: #002200;">:</span>UITableViewCellStyleSubtitle reuseIdentifier<span style="color: #002200;">:</span>CellIdent<span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#125;</span>
&nbsp;
  <span style="color: #11740a; font-style: italic;">// Configure the cell...</span>
  ACAccount <span style="color: #002200;">*</span>account <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self.accounts objectAtIndex<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>indexPath row<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
  cell.textLabel.text <span style="color: #002200;">=</span> account.username;
  cell.detailTextLabel.text <span style="color: #002200;">=</span> account.accountDescription;
  cell.accessoryType <span style="color: #002200;">=</span> UITableViewCellAccessoryDisclosureIndicator;
  <span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<h2>Displaying the public timeline of the selected user</h2>
<p>When the user selects one of the accounts, we want to display a list of recent tweets for this selected account. We&#8217;ll use <code>TWRequest</code> to fetch the list of recent tweets. </p>
<p><code>TWRequest</code> is the centerpiece of the iOS Twitter Framework and relieves us of the burden of having to perform OAuth authentication and request signing on our own. In order for it to do this, we need to provide a reference to the account whose timeline we want to read. We also need to provide the URL of the Twitter API endpoint we want to access. While this might seem a little bit cumbersome at first, this allows us to access not only current API calls but also any new APIs Twitter might come up with in the future without requiring Apple to update the API. Pretty nifty.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>fetchData
<span style="color: #002200;">&#123;</span>
  TWRequest <span style="color: #002200;">*</span>postRequest <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>TWRequest alloc<span style="color: #002200;">&#93;</span> 
    initWithURL<span style="color: #002200;">:</span>
      <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;https://api.twitter.com/1/statuses/home_timeline.json&quot;</span><span style="color: #002200;">&#93;</span> 
    parameters<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> 
    requestMethod<span style="color: #002200;">:</span>TWRequestMethodGET<span style="color: #002200;">&#93;</span>;
&nbsp;
  <span style="color: #002200;">&#91;</span>postRequest setAccount<span style="color: #002200;">:</span>self.account<span style="color: #002200;">&#93;</span>;    
  <span style="color: #002200;">&#91;</span>postRequest performRequestWithHandler<span style="color: #002200;">:^</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSData</span> <span style="color: #002200;">*</span>responseData, 
                                           <span style="color: #400080;">NSHTTPURLResponse</span> <span style="color: #002200;">*</span>urlResponse, 
                                           <span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>error<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>urlResponse statusCode<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> <span style="color: #2400d9;">200</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
      <span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>jsonError <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
      self.timeline <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSJSONSerialization JSONObjectWithData<span style="color: #002200;">:</span>responseData 
                                                      options<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span> 
                                                        error<span style="color: #002200;">:&amp;</span>jsonError<span style="color: #002200;">&#93;</span>;
      dispatch_sync<span style="color: #002200;">&#40;</span>dispatch_get_main_queue<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>, <span style="color: #002200;">^</span><span style="color: #002200;">&#123;</span>
        <span style="color: #002200;">&#91;</span>self.tableView reloadData<span style="color: #002200;">&#93;</span>;
      <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#41;</span>;
    <span style="color: #002200;">&#125;</span>
  <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>Again, we need to provide a completion handler which will be invoked as soon as the call to Twitter returns. As you can also see, we&#8217;re using the same approach as before to make sure we update the UI from the UI thread. It&#8217;s also interesting to see Apple provides us with their own JSON parsing framework &#8211; no longer do we need to integrate third party libraries to serialize / deserialize JSON data.</p>
<h2>Sending Tweets</h2>
<p>So far, we can choose a Twitter account from the list of Twitter accounts on our iPhone and display the home timeline of this particular user. But how about sending a tweet?</p>
<p>Sending tweets is really easy: you just have to instantiate a new <code>TWTweetComposeViewController</code> and display it &#8211; iOS will take care of the rest:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>composeTweet
<span style="color: #002200;">&#123;</span>
  TWTweetComposeViewController <span style="color: #002200;">*</span>tweetComposeViewController <span style="color: #002200;">=</span> 
    <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>TWTweetComposeViewController alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>tweetComposeViewController setCompletionHandler<span style="color: #002200;">:</span>
    <span style="color: #002200;">^</span><span style="color: #002200;">&#40;</span>TWTweetComposeViewControllerResult result<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span>self dismissModalViewControllerAnimated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#125;</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#91;</span>self presentModalViewController<span style="color: #002200;">:</span>tweetComposeViewController animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>The completion handler is merely needed to dismiss the tweet composition view after the tweet has been sent.</p>
<h2>Conclusion</h2>
<p>Integrating Twitter in your own apps has never been easier. With just a few lines of code, we implemented a basic version of a Twitter client that you can use to display a user&#8217;s home timeline and send tweets. Elaborating this code base is left as an exercise to you &#8211; feel free to <a href="http://github.com/peterfriese/TwitterClient">fork the code on Github</a> and send me pull requests as you add interesting features!</p>
<p>Here&#8217;s an impression of the current state of the application:</p>

<a href='http://www.peterfriese.de/the-accounts-and-twitter-framework-on-ios-5/twitterclient1/' title='Twitter Client: list of local accounts'><img width="150" height="150" src="http://www.peterfriese.de/wp-content/TwitterClient1-150x150.png" class="attachment-thumbnail" alt="Twitter Client: list of local accounts" title="Twitter Client: list of local accounts" /></a>
<a href='http://www.peterfriese.de/the-accounts-and-twitter-framework-on-ios-5/twitterclient2/' title='Twitter Client: home timeline for a user'><img width="150" height="150" src="http://www.peterfriese.de/wp-content/TwitterClient2-150x150.png" class="attachment-thumbnail" alt="Twitter Client: home timeline for a user" title="Twitter Client: home timeline for a user" /></a>
<a href='http://www.peterfriese.de/the-accounts-and-twitter-framework-on-ios-5/twitterclient3/' title='Twitter Client: composing a tweet'><img width="150" height="150" src="http://www.peterfriese.de/wp-content/TwitterClient3-150x150.png" class="attachment-thumbnail" alt="Twitter Client: composing a tweet" title="Twitter Client: composing a tweet" /></a>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=sqDykV_1QMY:Lalo3gYVX5Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=sqDykV_1QMY:Lalo3gYVX5Q:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=sqDykV_1QMY:Lalo3gYVX5Q:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=sqDykV_1QMY:Lalo3gYVX5Q:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=sqDykV_1QMY:Lalo3gYVX5Q:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=sqDykV_1QMY:Lalo3gYVX5Q:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=sqDykV_1QMY:Lalo3gYVX5Q:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=sqDykV_1QMY:Lalo3gYVX5Q:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=sqDykV_1QMY:Lalo3gYVX5Q:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=sqDykV_1QMY:Lalo3gYVX5Q:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=sqDykV_1QMY:Lalo3gYVX5Q:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=sqDykV_1QMY:Lalo3gYVX5Q:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/sqDykV_1QMY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/the-accounts-and-twitter-framework-on-ios-5/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/the-accounts-and-twitter-framework-on-ios-5/</feedburner:origLink></item>
		<item>
		<title>Tired of Typing? Speak to Your Computer!</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/p19rNOF9tAk/</link>
		<comments>http://www.peterfriese.de/tired-of-typing-speak-to-your-computer/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 14:54:39 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[speech]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=773</guid>
		<description><![CDATA[For some reason, humans have always dreamt of using natural language to communicate with computers. Quite a number of movies have been made that revolve around this theme, 2001: A Space Odyssey and I, Robot (named after the great collection of SF stories by Isaac Asimov) just being two of them. Well, we&#8217;ve come a [...]]]></description>
			<content:encoded><![CDATA[<p>For some reason, humans have always dreamt of using natural language to communicate with computers. Quite a number of movies have been made that revolve around this theme, <a href="http://en.wikipedia.org/wiki/2001:_A_Space_Odyssey">2001: A Space Odyssey</a> and <a href="http://en.wikipedia.org/wiki/I,_Robot_(film)">I, Robot</a> (named after the <a href="http://en.wikipedia.org/wiki/I_robot">great collection of SF stories</a> by <a href="http://en.wikipedia.org/wiki/Isaac_Asimov">Isaac Asimov</a>) just being two of them.<br />
<span id="more-773"></span><br />
Well, we&#8217;ve come a long way since then and computers are more powerful than ever before. I remember using one of the first versions of <a href="http://www.research.ibm.com/hlt/html/body_history.html">IBM ViaVoice</a> which would quite literally bog down my computer when I tried using it. The quality of speech recognition software has vastly improved and using a clever stack of technology, you can even use speech recognition on your iPhone (the <a href="http://www.tuaw.com/2009/12/08/dragon-dictation-comes-to-the-iphone-wow/">actual recognition is performed on a server</a>, but the effect is stunning nevertheless).</p>
<p>With all the hoopla around HTML 5, it would be quite a surprise if modern browsers didn&#8217;t have something in store with regard to voice recognition. And sure enough, there is a W3C specification for a <a href="http://lists.w3.org/Archives/Public/public-xg-htmlspeech/2011Feb/att-0020/api-draft.html">Speech Input API</a>. Looking at the list of authors might give us a hint as to which browser might support this API&#8230;</p>
<p>Using the speech input API is rather easy. All you have to do is to add the <code>x-webkit-speech</code> attribute to any <code>input</code> tag and you&#8217;re done. If you&#8217;re on a speech-enabled browsers (as of this writing, <a href="http://chrome.blogspot.com/2011/04/everybodys-talking-and-translating-with.html">only Chrome 11</a> supports this out of the box), you can check it out in the input field below. Just click on the microphone icon and start speaking:</p>
<p><input name="speechinput" size="40" placeholder="click the mic and start speaking" x-webkit-speech/></p>
<p>So, the other day I thought, &#8220;wouldn&#8217;t it be cool if I could use voice recognition to look up my contacts on the social networks I am on?&#8221;. Adding voice recognition support to a website you own is rather easy, as you only have to add the <code>x-webkit-speech</code> attribute to the respective input fields. Enhancing foreign sites, however, turns out to be a little bit more involved. Fortunately, Chrome can augment existing websites by way of so-called <a href="http://code.google.com/chrome/extensions/content_scripts.html">Content Scripts</a>, which are a part of the <a href="http://code.google.com/chrome/extensions/getstarted.html">Chrome Extensions API</a>.</p>
<p>Writing a Chrome Extension for speech-enabling existing text input fields on just about any website <a href="http://github.com/peterfriese/Speak2Search">was a matter of minutes</a>, thanks to the good documentation and some <a href="http://jquery.com/">jQuery</a> to walk the DOM. Putting on the finishing touches took me some more time, and I am proud to present you <a href="http://chrome.google.com/webstore/detail/peldinpdedgdcbdehomnpfndejpoibeb">Speak to Search</a> &#8211; a Chrome Extension that lets you talk with your browser. It works with virtually every website that uses regular HTML input fields. By making some smart assumptions, the extension will automatically submit the current form if the input field is a search field. If it is not, the focus will remain in the field and the form will not be submitted. That way, you can fill out e.g. an address form.</p>
<p>Here is a short video of me using Speak to Search to search for some people on Xing and LinkedIn. Please note that the extension is making sure the speech recognition engine is configured to recognize German names on Xing.</p>
<p><iframe width="610" height="347" src="http://www.youtube.com/embed/syMpQqMJcKU?hd=1" frameborder="0" allowfullscreen></iframe></p>
<p>Language makes us human &#8211; this is a quote from a <a href="http://www.pbs.org/wnet/humanspark/video/spark-blog-video-dr-steven-pinker-language-makes-us-human/212/">video</a> I found during the research for this blog post. I don&#8217;t necessarily think voice recognition and speech synthesis will make computers more human, but both technologies certainly can help to create a more immersive experience. I am looking forward to seeing a broader use of the new audio capabilities of modern browsers. Feel free to <a href="http://github.com/peterfriese/Speak2Search">grab my code from Github</a> and create something new and exciting!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=p19rNOF9tAk:P0SmTjtW7tE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=p19rNOF9tAk:P0SmTjtW7tE:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=p19rNOF9tAk:P0SmTjtW7tE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=p19rNOF9tAk:P0SmTjtW7tE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=p19rNOF9tAk:P0SmTjtW7tE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=p19rNOF9tAk:P0SmTjtW7tE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=p19rNOF9tAk:P0SmTjtW7tE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=p19rNOF9tAk:P0SmTjtW7tE:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=p19rNOF9tAk:P0SmTjtW7tE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=p19rNOF9tAk:P0SmTjtW7tE:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=p19rNOF9tAk:P0SmTjtW7tE:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=p19rNOF9tAk:P0SmTjtW7tE:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/p19rNOF9tAk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/tired-of-typing-speak-to-your-computer/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/tired-of-typing-speak-to-your-computer/</feedburner:origLink></item>
		<item>
		<title>Code Generation 2011 – Don’t miss out!</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/ZiWNZWiio9w/</link>
		<comments>http://www.peterfriese.de/code-generation-2011-dont-miss-out/#comments</comments>
		<pubDate>Sat, 21 May 2011 08:09:11 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[MDSD]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[Domain Specific Languages]]></category>
		<category><![CDATA[DSLs]]></category>
		<category><![CDATA[Language Workbench]]></category>
		<category><![CDATA[LOP]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=758</guid>
		<description><![CDATA[Code Generation 2011 is just around the corner and if you haven&#8217;t booked yet, you should hurry up &#8211; a few places are still available! Quite a number of my colleagues at itemis have been busy preparing for this conference in the past few weeks. Besides working hard to hit the Eclipse Release Train milestone [...]]]></description>
			<content:encoded><![CDATA[<p>Code Generation 2011 is <a href="http://www.codegeneration.net/cg2011/index.php">just around the corner</a> and if you haven&#8217;t booked yet, <a href="http://evbk.software-acumen.com/makebooking.php?event=CG2011">you should hurry up</a> &#8211; a few places are still available!</p>
<p>Quite a number of my colleagues at itemis have been busy preparing for this conference in the past few weeks. Besides working hard to hit the <a href="http://wiki.eclipse.org/Indigo/Simultaneous_Release_Plan">Eclipse Release Train milestone for Indigo on June 22nd</a>, the Xtext team brushed up their hands-on sessions &#8220;<a href="http://www.codegeneration.net/cg2011/sessioninfo.php?session=17">Xtext Take I: Creating Code Generators with Xtend2</a>&#8221; and &#8220;<a href="http://www.codegeneration.net/cg2011/sessioninfo.php?session=16">Xtext Take II: Crafting Domain Specific Languages with Xtext and Xbase</a>&#8220;. If you&#8217;ve been using Xtext, you&#8217;re well aware of the power you have at your disposal with this tool. Xbase and Xtend2, however, take this experience to a whole new level. So make sure to mark your calendar for these two sessions!<br />
<span id="more-758"></span><br />
But not only the Xtext team will share their expertise at CG2011 &#8211; Markus and Karsten will be also be in town to give hands-on tutorials and report from their experience:</p>
<ul>
<li><a href="http://www.codegeneration.net/cg2011/sessioninfo.php?session=22">Type Systems for DSLs (Markus Völter)</a></li>
<li><a href="http://www.codegeneration.net/cg2011/sessioninfo.php?session=8">Graphiti + Xtext: mixing graphical and textual DSLs for sprayers/designers (Karsten Thoms / Bernhard Merkle)</a></li>
<li><a href="http://www.codegeneration.net/cg2011/sessioninfo.php?session=5">Introduction to JetBrains Meta Programming System (MPS) (Markus Völter)</a></li>
</ul>
<p>The finale of the conference will be a panel discussion hosted by Markus on the topic of &#8220;<a href="http://www.codegeneration.net/cg2011/sessioninfo.php?session=20">Models, DSLs, Transformations: The Next 5 years</a>&#8221; &#8211; this should be a very interesting and lively discussion!</p>
<p><a href="http://lanyrd.com/people/hbehrens/">Heiko</a> <a href="http://lanyrd.com/people/peterfriese/">and I</a> will present &#8220;<a href="http://www.codegeneration.net/cg2011/sessioninfo.php?session=28">Cross-Platform Mobile Development with DSLs</a>&#8221; &#8211; a <a href="http://lanyrd.com/2011/cg2011/sdpgm/">fast-paced and fun mixture of slides, live coding (or modeling, if you will), videos and audience interaction</a>. Yes, that&#8217;s right &#8211; the audience will be part of the show. Make sure to bring your web-enabled mobile phone and get the chance to win a price!</p>
<p>To keep track of the conference program(me), we at <a href="http://mobile.itemis.com">itemis mobile</a> have been busy to create a conference planner for your iOS and Android powered mobile phones. Here are the download links:</p>
<ul>
<li>Apple App Store: <a href="http://itunes.apple.com/us/app/code-generation-2011/id436689925?mt=8">Code Generation 2011</a></li>
<li>Android Market Place: <a href="https://market.android.com/details?id=de.itemis.mobile.android.cg2011&#038;feature=search_result">Code Generation 2011</a></li>
</ul>
<div id="attachment_764" class="wp-caption aligncenter" style="width: 510px"><a class="lightbox"  title ="Code Generation 2011 Apps for iPhone and Android. Image courtesy of Heiko Behrens' impossible image skewing service" href="http://www.peterfriese.de/wp-content/cg2011.png"><img src="http://www.peterfriese.de/wp-content/cg2011-e1305966137679.png" alt="Code Generation 2011 Apps for iPhone and Android" title="Code Generation 2011 Apps for iPhone and Android" width="500" height="542" class="size-full wp-image-764" /></a><p class="wp-caption-text">Code Generation 2011 Apps for iPhone and Android</p></div>
<p>If you like the apps, please use the feedback feature of the respective store. Got comments or suggestions for improvement? <a href="mailto:mobile@itemis.de">Drop us a note</a> or track us down at the conference (best chance to see us: <a href="http://www.codegeneration.net/cg2011/sessioninfo.php?session=28">come to our talk</a> <img src='http://www.peterfriese.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ).</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=ZiWNZWiio9w:zZpjAvbSRRQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=ZiWNZWiio9w:zZpjAvbSRRQ:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=ZiWNZWiio9w:zZpjAvbSRRQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=ZiWNZWiio9w:zZpjAvbSRRQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=ZiWNZWiio9w:zZpjAvbSRRQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=ZiWNZWiio9w:zZpjAvbSRRQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=ZiWNZWiio9w:zZpjAvbSRRQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=ZiWNZWiio9w:zZpjAvbSRRQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=ZiWNZWiio9w:zZpjAvbSRRQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=ZiWNZWiio9w:zZpjAvbSRRQ:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=ZiWNZWiio9w:zZpjAvbSRRQ:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=ZiWNZWiio9w:zZpjAvbSRRQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/ZiWNZWiio9w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/code-generation-2011-dont-miss-out/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/code-generation-2011-dont-miss-out/</feedburner:origLink></item>
		<item>
		<title>Using NSPredicate to Filter Data</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/QsK8tSrufCo/</link>
		<comments>http://www.peterfriese.de/using-nspredicate-to-filter-data/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 20:15:36 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[nsarray]]></category>
		<category><![CDATA[nspredicate]]></category>
		<category><![CDATA[predicate]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=725</guid>
		<description><![CDATA[Filtering data is one of the essential tasks in computing. With all the data available today, we need to apply certain limits and constraints to actually make it usable. What use is it to be able to scroll down a list of literally thousands of list items when you really care about one or two [...]]]></description>
			<content:encoded><![CDATA[<p>Filtering data is one of the essential tasks in computing. With all the data available today, we need to apply certain limits and constraints to actually make it usable. What use is it to be able to scroll down a list of literally thousands of list items when you really care about one or two of them? Filtering and searching information make up a significant part of our work day &#8211; each time you use Google, you&#8217;re applying a filter to the huge set of data we call the internet.<br />
<span id="more-725"></span><br />
Even on your local computer, you use services like Spotlight or the search field in your mail application all the time. Apps that lack decent searching and filtering capabilities sometimes are really hard to use, so as developers we should spend some time on thinking how to allow users to filter the data they&#8217;re dealing with.</p>
<p>In this post, I am going to focus on ways to filter data. We won&#8217;t be looking at the UI side of things &#8211; this is something I&#8217;ll do in a subsequent blog post.</p>
<h2>Old-skool filtering</h2>
<p>If you look at an arbitrary code base, chances are you&#8217;ll sooner or later run into a piece of code similar to this one:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSMutableArray</span> <span style="color: #002200;">*</span>oldSkoolFiltered <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableArray</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>Book <span style="color: #002200;">*</span>book <span style="color: #a61390;">in</span> bookshelf<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>book.publisher isEqualToString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apress&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        <span style="color: #002200;">&#91;</span>oldSkoolFiltered addObject<span style="color: #002200;">:</span>book<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>It&#8217;s a straight-forward approach to filtering an array of items (in this case, we&#8217;re talking about books) using a rather simple <code>if</code>-statement. Nothing wrong with this, but despite the fact we&#8217;re using a fairly simple expression here, the code is rather verbose. We can easily imagine what will happen in case we need to use more complicated selection criteria or a combination of filtering criteria.</p>
<h2>Simple filtering with NSPredicate</h2>
<p>Thanks to Cocoa, we can simplify the code by using <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSPredicate_Class/Reference/NSPredicate.html">NSPredicate</a>. <code>NSPredicate</code> is the object representation of an if-statement, or, more formally, a predicate.</p>
<p>Predicates are <a href="http://en.wikipedia.org/wiki/Predicate_(mathematical_logic)">expressions that evaluate to a truth value</a>, i.e. <code>true</code> or <code>false</code>. We can use them to perform validation and filtering. In Cocoa, we can use <code>NSPredicate</code> to evaluate single objects, filter arrays and perform queries against Core Data data sets.</p>
<p>Let&#8217;s have a look at how our example looks like when using <code>NSPredicate</code>:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><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;publisher == %@&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apress&quot;</span> <span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>filtered  <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>bookshelf filteredArrayUsingPredicate<span style="color: #002200;">:</span>predicate<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>Much shorter and better readable!</p>
<h2>Filtering with Regular Expressions</h2>
<p>Regular Expressions can be used to <a href="http://xkcd.com/208/">solve almost any problem <img src='http://www.peterfriese.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </a> so it&#8217;s good to know you can use them in <code>NSPredicate</code>s as well. To use regular expressions in your <code>NSPredicate</code>, you need to use the <code>MATCHES</code> operator.</p>
<p>Let&#8217;s filter all books that are about iPad or iPhone programming:</p>
<pre>
predicate = [NSPredicate predicateWithFormat:@"title MATCHES '.*(iPhone|iPad).*'"];
filtered = [bookshelf filteredArrayUsingPredicate:predicate];
dumpBookshelf(@"Books that contain 'iPad' or 'iPhone' in their title", filtered);
</pre>
<p>You need to obey some rules when using regular expressions in <code>NSPredicate</code>: most importantly, <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Predicates/Articles/pUsing.html#//apple_ref/doc/uid/TP40001794-SW9">you cannot use regular expression metacharacters inside a pattern set</a>.</p>
<h2>Filtering using set operations</h2>
<p>Let&#8217;s for a moment assume you want to filter all books that have been published by your favorite publishers. Using the <code>IN</code> operator, this is rather simple: first, we need to set up a set containing the publishers we&#8217;re interested in. Then, we can create the predicate and finally perform the filtering operation:</p>
<pre>NSArray *favoritePublishers = [NSArray arrayWithObjects:@"Apress", @"O'Reilly", nil];
predicate = [NSPredicate predicateWithFormat:@"publisher IN %@", favoritePublishers];
filtered  = [bookshelf filteredArrayUsingPredicate:predicate];
dumpBookshelf(@"Books published by my favorite publishers", filtered);</pre>
<h2>Advanced filtering thanks to KVC goodness</h2>
<p><code>NSPredicate</code> relies on <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/KeyValueCoding.html">key-value coding</a> to achieve its magic. On one hand this means your classes need to be <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/Compliant.html#//apple_ref/doc/uid/20002172-BAJEAIEE">KVC compliant</a> in order to be queried using <code>NSPredicate</code> (at least the attributes you want to query). On the other hand, this allows us to perform some very interesting things with very little lines of code.</p>
<p>Let&#8217;s for example retrieve a list of books written by authors with the name &#8220;Mark&#8221;:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;">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;authors.lastName CONTAINS %@&quot;</span>, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Mark&quot;</span> <span style="color: #002200;">&#93;</span>;
filtered  <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>bookshelf filteredArrayUsingPredicate<span style="color: #002200;">:</span>predicate<span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<p>In case we&#8217;d want to return the value of one of the aggregate functions, we don&#8217;t need to use NSPredicate itself, but instead use KVC directly. Let&#8217;s retrieve the average price of all books on our shelf:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSNumber</span> <span style="color: #002200;">*</span>average <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>bookshelf valueForKeyPath<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;@avg.price&quot;</span><span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>

<h2>Conclusion</h2>
<p>The Cocoa libraries provide some very powerful abstractions which can make your life and that of the people reading your code much easier. It pays off to know about them, so go ahead and browse the Cocoa documentation and hunt for those gems!</p>
<p>Apple&#8217;s <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Predicates/predicates.html">NSPredicate programming guide</a> provides an in-depth documentation for <code>NSPredicate</code> containing all the things I didn&#8217;t cover in this post.</p>
<p><code>NSPredicate</code> also plays an important role when querying data in Core Data, something we will need to have a look at in one of the next blog posts. Stay tuned!</p>
<h2>Code</h2>
<p>The code for this post is available on my github page: <a href="http://github.com/peterfriese/NSPredicateDemo">get forking</a>!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=QsK8tSrufCo:fZITiaoTXys:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=QsK8tSrufCo:fZITiaoTXys:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=QsK8tSrufCo:fZITiaoTXys:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=QsK8tSrufCo:fZITiaoTXys:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=QsK8tSrufCo:fZITiaoTXys:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=QsK8tSrufCo:fZITiaoTXys:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=QsK8tSrufCo:fZITiaoTXys:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=QsK8tSrufCo:fZITiaoTXys:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=QsK8tSrufCo:fZITiaoTXys:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=QsK8tSrufCo:fZITiaoTXys:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=QsK8tSrufCo:fZITiaoTXys:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=QsK8tSrufCo:fZITiaoTXys:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/QsK8tSrufCo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/using-nspredicate-to-filter-data/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/using-nspredicate-to-filter-data/</feedburner:origLink></item>
		<item>
		<title>Save a Tree, Put EclipseCon 2011 in Your Pocket</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/rnHbIRj1-RM/</link>
		<comments>http://www.peterfriese.de/save-a-tree-put-eclipsecon-2011-in-your-pocket/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 20:15:57 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=709</guid>
		<description><![CDATA[After the huge success of the mobile apps for Eclipse Summit Europe, we decided to provide mobile apps for EclipseCon 2011, too. So instead of using a printed copy of the conference program, you can browse the schedule on your smart phone &#8211; wherever you are! This year, we&#8217;re providing a rather impressive lineup of [...]]]></description>
			<content:encoded><![CDATA[<p>After the huge success of the mobile apps for Eclipse Summit Europe, we decided to provide mobile apps for EclipseCon 2011, too. So instead of using a printed copy of the conference program, you can browse the schedule on your smart phone &#8211; wherever you are! <span id="more-709"></span>This year, we&#8217;re providing a rather impressive lineup of mobile apps for iPhone, iPod Touch, iPad (thanks to <a href="http://www.compeople.eu/blog/?p=786">Christian Campo who created a stand-alone iPad app</a>), BlackBerry (<a href="http://ekkes-apps.org/">Ekke is working on a updated version, AFAIK</a>), and all other smart phones that feature a browser.</p>
<p>All apps allow you to browse the program, select your favorite talks and get to know the speakers (with headshots so you recognise them in the hallways). We also have included maps of the convention center as well as Santa Clara.</p>
<p>For a first glimpse, watch our video:</p>
<p><iframe src="http://player.vimeo.com/video/20377509?title=0&amp;byline=0&amp;portrait=0&amp;autoplay=1&amp;loop=1" width="501" height="313" frameborder="0" style="display:block; margin-left:auto; margin-right:auto;"></iframe></p>
<p>As of today, both iPhone and Android users can download the apps from the Apple App Store respectively the Android Marketplace. Here are the links:</p>
<ol>
<li><a href="http://bit.ly/econ2011iphone">EclipseCon 2011 iPhone App</a></li>
<li><a href="http://bit.ly/econ2011android">EclipseCon 2011 Android App</a></li>
</ol>
<p>If you don&#8217;t own an iPhone or Android, you can always use the HTML-only version of the conference program available at <a href="http://bit.ly/econ2011html">http://bit.ly/econ2011html</a>.</p>
<p>The iPad and BlackBerry apps will be available soon, so stay tuned!</p>
<p>By the way, if <strong>you</strong> run a conference and are interested in having an app like this, <a href="http://mobile.itemis.com">get in touch with us</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=rnHbIRj1-RM:Quf4zh4pZaY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=rnHbIRj1-RM:Quf4zh4pZaY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=rnHbIRj1-RM:Quf4zh4pZaY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=rnHbIRj1-RM:Quf4zh4pZaY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=rnHbIRj1-RM:Quf4zh4pZaY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=rnHbIRj1-RM:Quf4zh4pZaY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=rnHbIRj1-RM:Quf4zh4pZaY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=rnHbIRj1-RM:Quf4zh4pZaY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=rnHbIRj1-RM:Quf4zh4pZaY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=rnHbIRj1-RM:Quf4zh4pZaY:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=rnHbIRj1-RM:Quf4zh4pZaY:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=rnHbIRj1-RM:Quf4zh4pZaY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/rnHbIRj1-RM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/save-a-tree-put-eclipsecon-2011-in-your-pocket/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/save-a-tree-put-eclipsecon-2011-in-your-pocket/</feedburner:origLink></item>
		<item>
		<title>Appropriate Use of MapKit</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/0hUhPirtGiQ/</link>
		<comments>http://www.peterfriese.de/appropriate-use-of-mapkit/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 08:48:38 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[MapKit]]></category>
		<category><![CDATA[googlemaps]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[terms of service]]></category>
		<category><![CDATA[TOS]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=689</guid>
		<description><![CDATA[I just had an app rejected because of violation of the Google Maps terms of service. While it certainly is kind of funny Apple rejects an app because you&#8217;re violating Google&#8217;s terms of service, I was wondering what in particular was wrong. At first sight, everything looked OK. Have a look at the following screenshot. [...]]]></description>
			<content:encoded><![CDATA[<p>I just had an app rejected because of violation of the Google Maps terms of service. While it certainly is kind of funny Apple rejects an app because you&#8217;re violating Google&#8217;s terms of service, I was wondering what in particular was wrong. <span id="more-689"></span>At first sight, everything looked OK. Have a look at the following screenshot. It clearly violates <a href="http://code.google.com/apis/maps/terms.html">Google&#8217;s terms of service for Maps</a>, but can you spot what is wrong?</p>
<div id="attachment_687" class="wp-caption aligncenter" style="width: 182px"><a class="lightbox"  title ="Google Maps in your app" href="http://www.peterfriese.de/wp-content/maps_without_google_logo.png"><img src="http://www.peterfriese.de/wp-content/maps_without_google_logo-172x300.png" alt="Google Maps in your app - without Google Logo: you&#039;re doing it wrong!" title="No logo? You're doing it wrong!" width="172" height="300" class="size-medium wp-image-687" /></a><p class="wp-caption-text">What's wrong with this map?</p></div>
<p>Maybe you can better see what&#8217;s wrong when I show you another screenshot, this time obeying the TOS:</p>
<div id="attachment_688" class="wp-caption aligncenter" style="width: 179px"><a class="lightbox"  title ="Google Maps in your app" href="http://www.peterfriese.de/wp-content/maps_with_google_logo.png"><img src="http://www.peterfriese.de/wp-content/maps_with_google_logo-169x300.png" alt="Google Maps with logo: well done!" title="Google Maps with logo" width="169" height="300" class="size-medium wp-image-688" /></a><p class="wp-caption-text">With logo: well done!</p></div>
<p>Can you spot the difference? It&#8217;s the Google logo!</p>
<p>The reason why it is not shown in the first screenshot is that the bounds for the map are not set correctly. In the offending version of my app, I used a piece of code similar to this one:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad <span style="color: #002200;">&#123;</span>
  <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;
  mapView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>MKMapView alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>self.view.bounds<span style="color: #002200;">&#93;</span>;
&nbsp;
  mapView.showsUserLocation<span style="color: #002200;">=</span>TRUE;
  mapView.mapType<span style="color: #002200;">=</span>MKMapTypeStandard;
  <span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>mapView<span style="color: #002200;">&#93;</span>;		
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>Nothing wrong with it, but it lacks one essential line:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad <span style="color: #002200;">&#123;</span>
  <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;
  mapView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>MKMapView alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>self.view.bounds<span style="color: #002200;">&#93;</span>;
&nbsp;
  mapView.autoresizingMask <span style="color: #002200;">=</span> 
    <span style="color: #002200;">&#40;</span>UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight<span style="color: #002200;">&#41;</span>;	
&nbsp;
  mapView.showsUserLocation<span style="color: #002200;">=</span>TRUE;
  mapView.mapType<span style="color: #002200;">=</span>MKMapTypeStandard;
  <span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>mapView<span style="color: #002200;">&#93;</span>;		
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>So, next time you write an app that contains Google Maps, make sure the Google logo is visible. You can get the full source code for this example <a href="http://github.com/peterfriese/MapKitSample">on my GitHub page</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=0hUhPirtGiQ:zBq613eVsN4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=0hUhPirtGiQ:zBq613eVsN4:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=0hUhPirtGiQ:zBq613eVsN4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=0hUhPirtGiQ:zBq613eVsN4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=0hUhPirtGiQ:zBq613eVsN4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=0hUhPirtGiQ:zBq613eVsN4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=0hUhPirtGiQ:zBq613eVsN4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=0hUhPirtGiQ:zBq613eVsN4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=0hUhPirtGiQ:zBq613eVsN4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=0hUhPirtGiQ:zBq613eVsN4:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=0hUhPirtGiQ:zBq613eVsN4:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=0hUhPirtGiQ:zBq613eVsN4:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/0hUhPirtGiQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/appropriate-use-of-mapkit/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/appropriate-use-of-mapkit/</feedburner:origLink></item>
		<item>
		<title>Three reasons why I think the HP TouchPad will rock the tablet market</title>
		<link>http://feedproxy.google.com/~r/FormFollowsFunction/~3/7xrEP2jjNCs/</link>
		<comments>http://www.peterfriese.de/three-reasons-why-i-think-the-hp-touchpad-will-rock-the-tablet-market/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 08:38:26 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[HP]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[TouchPad]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=668</guid>
		<description><![CDATA[Yesterday, HP introduced the Touchpad, an iPad-like tablet device that is programmed with web technologies. While this certainly isn&#8217;t the first attempt of a vendor to compete with Apple on the tablet market, I am convinced the TouchPad is a true challenger to the iPad. There are three reasons why the TouchPad might be a [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, <a href="http://www.engadget.com/2011/02/09/hp-posts-complete-think-beyond-event-video/">HP introduced</a> the <a href="http://www.palm.com/us/products/pads/touchpad/index.html">Touchpad</a>, an <del datetime="2011-02-10T23:30:52+00:00">iPad-like</del> tablet device that is programmed with web technologies. While this certainly isn&#8217;t the first attempt of a vendor to compete with Apple on the tablet market, I am convinced the TouchPad is a true challenger to the iPad. There are three reasons why the TouchPad might be a real contender: the programming environment, the manufacturing process and security. <span id="more-668"></span>HP is definitely doing something right. Never before has one single Tablet thrilled the interwebs as much as the TouchPad &#8211; except for the iPad, of course. Even <a href="http://scobleizer.com/2011/02/09/hp-makes-google-look-even-more-creaky/">die-hard Apple</a> fans are thrilled.</p>
<p>Here&#8217;s why I think HP&#8217;s TouchPad will score a considerable market share:</p>
<ol>
<li>It&#8217;s programmed with web technologies like HTML, CSS and JavaScript. Don&#8217;t get me wrong &#8211; the iPad can also be programmed with web technologies: when the iPhone was first released and no one but Apple was allowed to write native apps, Steve himself told everyone that &#8220;mobile web applications are the future&#8221;. And despite the fact Apple has opened it&#8217;s SDK and we can now program the iPad / iPhone in Objective-C, many developers are more interested in writing apps with web technologies. Tools like PhoneGap and Appcelerator try to alleviate this situation, basically allowing you to wrap web code in more or less tiny wrapper apps so your web apps can be submitted to the App Store. However, most apps written using web technologies do not feel the same as real native apps on the iOS platform. So why do I think the situation will be better on the TouchPad? Well, because the TouchPad has been built for running web-based apps! It has been optimized for it. Web apps look stunningly great on the TouchPad. Now, every web developer can download the webOS SDK and get started writing apps for the TouchPad. It&#8217;s a safe bet to assume there are more web developers out there than Objective-C developers, so it shouldn&#8217;t take long until we&#8217;ve got a similar amount of apps for the TouchPad as we&#8217;ve got for the iPad.</li>
<li>The manufacturing process. HP has a very powerful production pipeline, capable of pumping out high volumes of devices. In <a href="http://www.itchannelplanet.com/trends/article.php/3920936/Gartner-Global-PC-Shipments-Total-351-Million-Units-in-2010-Gain-138-Percent-US-Q4-PC-Market-Slides-Nearly-7-Percent.htm">Q4/2010, they shipped 17.6</a> million PCs (<a href="http://www.apple.com/pr/library/2011/01/18results.html">Apple sold 7.33 million iPads</a> in the same quarter). So if they are serious about it, it should be easy for HP to both produce and distribute high volumes of TouchPads.</i>
<li>Security. When it comes to enterprise computing, security becomes a vital feature of your product. CIOs need to make sure to not compromise their company&#8217;s security by introducing products and devices that have no proper support for security mechanisms. There have always been <a href="http://www.wired.com/gadgetlab/2009/07/iphone-encryption/">security concerns</a> with respect to the iOS platform: for a long time, there hasn&#8217;t been a way to nuke a lost iOS device remotely. <a href="http://support.apple.com/kb/HT4175">It wasn&#8217;t before iOS 4</a> that Apple introduced data protection APIs to secure data that apps store on the device. <a href="">WebOS has several security features built in</a> (not bolted on later) which make it rather attractive for enterprise computing right from the start.</li>
</ol>
<p>It&#8217;s my firm belief that the release of the HP TouchPad is a milestone for the perception of personal computing in the long run. It looks great, we&#8217;ll see tons of great apps for it in no time and HP as a major computer vendor has the power to push it to the market.</p>
<p>Good-bye, PC.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=7xrEP2jjNCs:t7HYhX1gy9I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=7xrEP2jjNCs:t7HYhX1gy9I:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=dnMXMwOfBR0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=7xrEP2jjNCs:t7HYhX1gy9I:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=7xrEP2jjNCs:t7HYhX1gy9I:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=7xrEP2jjNCs:t7HYhX1gy9I:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=7xrEP2jjNCs:t7HYhX1gy9I:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=7xrEP2jjNCs:t7HYhX1gy9I:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?i=7xrEP2jjNCs:t7HYhX1gy9I:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=7xrEP2jjNCs:t7HYhX1gy9I:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=7xrEP2jjNCs:t7HYhX1gy9I:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=TzevzKxY174" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=7xrEP2jjNCs:t7HYhX1gy9I:6stttfHX83w"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=6stttfHX83w" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/FormFollowsFunction?a=7xrEP2jjNCs:t7HYhX1gy9I:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/FormFollowsFunction?d=7Q72WNTAKBA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/FormFollowsFunction/~4/7xrEP2jjNCs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/three-reasons-why-i-think-the-hp-touchpad-will-rock-the-tablet-market/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://www.peterfriese.de/three-reasons-why-i-think-the-hp-touchpad-will-rock-the-tablet-market/</feedburner:origLink></item>
	</channel>
</rss>
