<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dr. Touch</title>
	<atom:link href="http://www.drobnik.com/touch/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.drobnik.com/touch</link>
	<description>Bitching and Stiching iPhone Apps (almost) since 1974</description>
	<lastBuildDate>Thu, 02 Sep 2010 13:05:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Backwards Compatibility if Apple Starts Polishing</title>
		<link>http://www.drobnik.com/touch/2010/09/backwards-compatibility-if-apple-starts-polishing/</link>
		<comments>http://www.drobnik.com/touch/2010/09/backwards-compatibility-if-apple-starts-polishing/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 13:00:09 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Recipes]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=3028</guid>
		<description><![CDATA[You can see that Apple is constantly polishing the APIs [...]]]></description>
			<content:encoded><![CDATA[<p>You can see that Apple is constantly polishing the APIs from version to version, but sometimes they make a more drastic change that breaks existing code. Well, not exactly &#8220;breaks&#8221;, but starts to show warnings about you daring to use deprecated methods. </p>
<p>One such change came out of their trying to adhere to their own naming conventions of methods. The second kind of late polishing is if there are new structures introduced without a matching Make macro for easy filling of said structures. I have an example for you, also in CoreLocation.</p>
<p>In this post I&#8217;m exploring two such changes and tell you how I dealt with them in a backwards compatible way.<br />
<span id="more-3028"></span></p>
<h3>A New Make Function</h3>
<p>CoreLocation has a structure CLLocationCoordinate2D which contains latitude and longitude in decimal degrees of any coordinate on Earth. Before 4.0 was introduced I figured that it would be handy to have a CLLocationCoordinate2DMake to go with it, just like you have CGRectMake to create and fill a CGRect.</p>
<p>Turns out, Apple thought so too, and because I guessed the naming convention correctly they introduced this exact method in 4.0 causing my Xcode to complain like this, if I expanded the build results.</p>
<pre>In file included from ../DTFloatingIconView.m:9:
../DTFloatingIconView.h:42: error: static declaration of 'CLLocationCoordinate2DMake' follows non-static declaration
/Developer_Stable/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocation.h:125: error: previous declaration of 'CLLocationCoordinate2DMake' was here</pre>
<p>In the code itself you could only see the first line, but the enlightening detail is found right underneath it. There&#8217;s obvious now a &#8220;previous declaration&#8221; of my helper function. It&#8217;s previous to my definition, because it&#8217;s in a header and headers precede your code always. And indeed if we have a look at CLLocation.h, there it is. Clearly marked as not available on Mac and available on iOS as of 4.0:</p>

<div class="wp_codebox"><table><tr id="p30281"><td class="code" id="p3028code1"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">/*
 *  CLLocationCoordinate2DMake:
 *
 *  Discussion:
 *    Returns a new CLLocationCoordinate2D at the given latitude and longitude
 */</span>
CLLocationCoordinate2D CLLocationCoordinate2DMake<span style="color: #002200;">&#40;</span>CLLocationDegrees latitude, CLLocationDegrees longitude<span style="color: #002200;">&#41;</span> __OSX_AVAILABLE_STARTING<span style="color: #002200;">&#40;</span>__MAC_NA,__IPHONE_4_0<span style="color: #002200;">&#41;</span>;</pre></td></tr></table></div>

<p>The question in this case was how I could modify my definition such that I could build with 4.0, targeting 3.0 and above and get no warnings, errors or crashes. Here&#8217;s how:</p>

<div class="wp_codebox"><table><tr id="p30282"><td class="code" id="p3028code2"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#if __IPHONE_OS_VERSION_MAX_ALLOWED &lt; __IPHONE_4_0</span>
<span style="color: #11740a; font-style: italic;">// this method was introduced in SDK 4.0</span>
<span style="color: #a61390;">static</span> inline CLLocationCoordinate2D CLLocationCoordinate2DMake<span style="color: #002200;">&#40;</span>CLLocationDegrees latitude, CLLocationDegrees longitude<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span> 
	CLLocationCoordinate2D coord;
	coord.latitude <span style="color: #002200;">=</span> latitude;
	coord.longitude <span style="color: #002200;">=</span> longitude;
	<span style="color: #a61390;">return</span> coord;
<span style="color: #002200;">&#125;</span>
<span style="color: #6e371a;">#endif</span></pre></td></tr></table></div>

<p>By using the preprocessor macro __IPHONE_OS_VERSION_MAX_ALLOWED I can check the used SDK version and if it is below 4.0 I define it. Marking it as static inline means that this is built into the binary not as function call, but this code is actually inserted into the calling method as if it were local code.</p>
<p>This way I have a function to satisfy the compiler regardless whether I&#8217;m building with SDK 3.x or 4.x. The reason for doing so is that I&#8217;m using this in DTAugmentedRealityController where I don&#8217;t want to force my customers to build with a specific SDK. So that&#8217;s how I implemented it in version 1.1 of the component.</p>
<p>BUT, thinking about it, there&#8217;s a problem when building this code with SDK 4.0 which happily compiles it and omits the new function. But what happens if this runs on a 3.x device? A crash with an unrecognized selector. In debugger you&#8217;d get something like this:</p>
<pre>
dyld: lazy symbol binding failed: Symbol not found: _CLLocationCoordinate2DMake
  Referenced from: /var/mobile/Applications/0E8F890C-F78A-4092-99A5-9466AF298D60/test.app/test
  Expected in: /System/Library/Frameworks/CoreLocation.framework/CoreLocation
</pre>
<p>So how do we make it backwards compatible?</p>
<p>The easiest way I could think of is somewhat brutal, because it involves basically redirecting all calls to my own function. But looking on the bright side, by making it an inline function we actually gain a few nanoseconds by not having to have the function call overhead.</p>

<div class="wp_codebox"><table><tr id="p30283"><td class="code" id="p3028code3"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">static</span> inline CLLocationCoordinate2D CLLocationCoordinate2DInlineMake<span style="color: #002200;">&#40;</span>CLLocationDegrees latitude, CLLocationDegrees longitude<span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span> 
	CLLocationCoordinate2D coord;
	coord.latitude <span style="color: #002200;">=</span> latitude;
	coord.longitude <span style="color: #002200;">=</span> longitude;
	<span style="color: #a61390;">return</span> coord;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #6e371a;">#define CLLocationCoordinate2DMake CLLocationCoordinate2DInlineMake</span></pre></td></tr></table></div>

<p>This replaces all CLLocationCoordinate2DMake in your code with CLLocationCoordinate2DInlineMake which is an inline function we define regardless of the used SDK or running OS.</p>
<p>It&#8217;s a nasty workaround, but at least it does not cause a crash. And we can keep on using the CLLocationCoordinate2DMake function name. That&#8217;s some consolidation until we can drop 3.x support later this year.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<h3>Renamed Function</h3>
<p>In 3.2 the method of CLLocation getDistanceFrom got renamed to distanceFromLocation. You might wonder why. Simple explanation really, Apple reserves the prefix get for methods that are using one or more of their parameters to return a value in addition to the regular return value. This is generally achieved by passing a pointer (= memory address) to the method which the method then can follow and modify the referenced piece of RAM.</p>
<p>Consider for example the method &#8211; (void)getValue:(void *)buffer of NSValue where the value of NSValue will be copied into the memory pointed to by &#8220;buffer&#8221;. There are very few such methods on the higher level APIs. Many more can be found on the Core Foundation level.</p>
<p>The naming convention seems to go that the first part of the method name tells you what is being returned, namely a distance and the last part before the first colon should tell what this parameter actually is. A name that at the same time tells it&#8217;s function. So they could have called it distanceThatWillBeCalculatedByAVeryComplicatedFormulaAndSoWeNeedASecondParameterThatIsALocation:, as long as the first and the last item in this camel-cased name. The second rule though is to non unnecessarily prolong method names if it&#8217;s possible to get by with 3 or 4 words. A distance from a location, distanceFromLocation. A sorted array by using a selector, sortedArrayUsingSelector.</p>
<p>There are a few such methods in the SDKs that snuck in under the radar of the Naming Convention Adherence Subcommittee at Apple HQ, so they chose to make the switch when introducing 3.2 because at this time that was the first iOS version running on the iPad and thus this change would not cause any problems there. I betcha there was somebody having sleepless nights over this until 3.2 was released in the form of the iPad. Now he can rest in peace.</p>
<p>But to bring balance to the force, somebody being able to rest means that somebody has extra work, we.  Because if we want to keep our code working and warning-free then we have to work around this change.</p>
<p>Since we will be using the latest SDK version for building the new method is valid and the old one is causing a deprecation warning. BUT because we want this code to work on previous iOS versions we cannot exclusively use the distanceFromLocation method, because this would cause an &#8220;unrecognized selector&#8221; exception (read &#8220;crash&#8221;) if somebody is running our app on iOS 3.1.x.</p>
<p>Usually you can work around this by using performSelector after having checked that the instance of the receiver responds to it. But in this case there&#8217;s a problem: we have a return value that we need to get hold of. I found some workarounds on the Internet that would hack and typecast around. But these methods upset my stomach, so I chose to go for the following method.</p>

<div class="wp_codebox"><table><tr id="p30284"><td class="code" id="p3028code4"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>CLLocationDistance<span style="color: #002200;">&#41;</span>distanceBetweenLocation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocation <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>location1 andLocation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocation <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>location2
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>location1 respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>distanceFromLocation<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>location1 distanceFromLocation<span style="color: #002200;">:</span>location2<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">SEL</span> sel <span style="color: #002200;">=</span> <span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>getDistanceFrom<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>location1 respondsToSelector<span style="color: #002200;">:</span>sel<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMethodSignature_Class/"><span style="color: #400080;">NSMethodSignature</span></a> <span style="color: #002200;">*</span>mySignature <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>CLLocation instanceMethodSignatureForSelector<span style="color: #002200;">:</span>sel<span style="color: #002200;">&#93;</span>;
		<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSInvocation_Class/"><span style="color: #400080;">NSInvocation</span></a> <span style="color: #002200;">*</span>myInvocation <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSInvocation_Class/"><span style="color: #400080;">NSInvocation</span></a> invocationWithMethodSignature<span style="color: #002200;">:</span>mySignature<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>myInvocation setArgument<span style="color: #002200;">:&amp;</span>location2 atIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">2</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>myInvocation setTarget<span style="color: #002200;">:</span>location1<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>myInvocation setSelector<span style="color: #002200;">:</span>sel<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>myInvocation invoke<span style="color: #002200;">&#93;</span>;
&nbsp;
		CLLocationDistance distance;
		<span style="color: #002200;">&#91;</span>myInvocation getReturnValue<span style="color: #002200;">:&amp;</span>distance<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #a61390;">return</span> distance;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">// should never get here</span>
	<span style="color: #a61390;">return</span> <span style="color: #2400d9;">0</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>Of course this could have been made as a category extension, but I chose not to because I didn&#8217;t want to have to name it distanceBackwardsCompatibleWith3xFromLocation. Reason being, that if you name a category extension method the same as an existing one you overwrite it and there&#8217;s no way (similar to super) to call the original method.</p>
<p>Let me explain the above code. </p>
<p>First location1 is asked if it knows distanceFromLocation, if YES, then this is called and we&#8217;re done.<br />
Then I&#8217;m creating a variable of type SEL to hold the signature (read &#8220;selector&#8221;) of the pre 3.2 method.<br />
At this point I could assume that this has to be present here, but just to be safe I&#8217;m asking again.<br />
Then I&#8217;m building an NSInvocation for this signature and setting as target location1.<br />
I&#8217;m executing the method by calling invoke.<br />
Then I&#8217;m creating a local variable which essentially prompts the compiler to reserve sufficient memory for it.<br />
Finally I&#8217;m retrieving the return value of the invocation.</p>
<p>Do you remember what I said about methods prefixed with &#8220;get&#8221;? That&#8217;s another example: it takes a pointer (which we get by the address operator &#038;) to point to the memory it is allowed to modify. Of course it&#8217;s your responsibility to have sufficient memory space allocated. We know that this method will return a CLLocationDistance (which is really just a double) I can take the above shown shortcut. Otherwise I&#8217;d have to inquire about the size of the return value. Possible, but unnecessary if you know the type.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<h3>Conclusion</h3>
<p>Regardless if it&#8217;s a new convenience function/method or a renaming, as a developer you have to start thinking on several levels at the same time: </p>
<p>1) which methods and functions does my building SDK know about<br />
2) which methods and functions does the executing iOS version know about</p>
<p>Of course you could keep ignoring deprecation warnings, or even go as far as keeping building against an outdated SDK. But your customers expect from you to offer them features that only became available in 4.0. At the same time you still want to get the money from the 3.x crowd. </p>
<p>It boils down to the necessity of having a 3.1 device next to your development Mac just so you can test the backwards compatibility.</p>
<p>So you have to create the compatibility methods, because Apple does not care about backwards compatibility. It&#8217;s in their interest that customers update as soon as possible because this decreases the possibility of jailbreaks.</p>
<p>Fun Fact: NSMakeRange still does not comply with Apple&#8217;s naming conventions (should be called NSRangeMake instead) and they HATE that. <img src='http://www.drobnik.com/touch/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/09/backwards-compatibility-if-apple-starts-polishing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple Music Event, Everything iOS!</title>
		<link>http://www.drobnik.com/touch/2010/09/apple-music-event-everything-ios/</link>
		<comments>http://www.drobnik.com/touch/2010/09/apple-music-event-everything-ios/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 18:40:14 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Apple]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=3021</guid>
		<description><![CDATA[The question that we developers are always asking ourse [...]]]></description>
			<content:encoded><![CDATA[<p>The question that we developers are always asking ourselves after such an Apple event: <em>&#8220;what was in it for us?&#8221;</em> There are the highlights relevant to us:</p>
<ul>
<li><strong>iOS 4.1</strong> release is imminent, if not today then this week. GameCenter being released, update your games! Ah and you don&#8217;t need any HDR app any more, the iPhone shots 3 images at the same time and combines them. Groovy!</li>
<li><strong>iOS 4.2</strong> coming in November, for all devices being able to run 4.x, but the main focus is to bring all the 4.0 niceties to iPad: Multitasking, Folders, etc. And the best new feature for productivity apps: Wireless Printing!</li>
<li>There are 230,000 iOS devices being activated every day, NOT including updates. Steve kind of hinted that the number that Google mentioned is not really honest in that regard.</li>
<li>The new <strong>iPod Nano</strong> is square indeed and clearly runs iOS. For the time being Apple does not give us ability to code apps for the small screen, but that might be coming eventually.</li>
<li>New<strong> iPod Touch</strong> is now an iPhone 4 without the phone. Retina display, Gyroscope, A4 Chip. Even more reason to update your artwork and add a 2x version for all images. And since the iPod Touch now has two cameras any apps making use of AV capture devices has a way bigger audience</li>
<li>New <strong>Apple TV</strong> is now at a price point reachable for everybody. The previous Apple TV was running an old OSX version, this new version clearly is iOS based, also because it has an A4 chip. But just like the Nano, no third party apps (yet?). It does not have storage though, so where would you store apps?</li>
<li>One of the new things in iOS 4.2 will be <strong>AirPlay</strong> which allows HD videos to be streamed from you iDevices straight to your AppleTV. Do we see a wireless UIScreen that we can do the same from our apps in 4.2?</li>
<li>New social music service directly in <strong>iTunes 10</strong>. You see which music your friends like. How about adding the same for apps?</li>
</ul>
<p>So half of the news is great for us, more iOS devices that we can develop for with new tech. And more iOS devices that we WILL be able to develop for. Everything points to Apple wanting to keep enough news to themselves to not over-excite us iOS developers.</p>
<p>BUT! (one more thing) I foresee another Apple event happening at the beginning of 2011 filling all the above mentioned holes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/09/apple-music-event-everything-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building the Ultimate iOS Source Store</title>
		<link>http://www.drobnik.com/touch/2010/08/building-the-ultimate-ios-source-store/</link>
		<comments>http://www.drobnik.com/touch/2010/08/building-the-ultimate-ios-source-store/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 05:53:11 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Business]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=3009</guid>
		<description><![CDATA[When I quit my employment as Windows system administrat [...]]]></description>
			<content:encoded><![CDATA[<p>When I quit my employment as Windows system administrator in December 2009 I had already been developing iOS stuff for 2 years. At that stage I had to define what my business should be comprised of and I decided on a <a href="http://www.drobnik.com/touch/2010/01/business-as-unusual/">multi-pronged approach</a>. I simply lack the design capabilities and ideas to sustain myself on apps alone.</p>
<h2>The Past</h2>
<p>One of the multiple streams of income that a holistic iOS business can generate are sales of <strong>software components</strong>. Often there&#8217;s a functionality that you wished Apple would provide or made simpler to use but you lack time and expertise to write such a component. And you lack funds to hire a professional at a rate of several hundred dollars per day. What if you could share the development cost with dozens of other fellow developers? The pro would still get payed, but you trade exclusivity for availability.</p>
<p>This is what I created my <a href="http://www.drobnik.com/touch/parts-store">Dr. Touch&#8217;s Parts Store</a> for.</p>
<p>Often I get asked, how this is going for me. Here&#8217;s my first go at answering that: pretty well! I&#8217;ve been doing that for 7 months now, which provides a bit of data that we can slice and dice. Also I&#8217;ll tell you about the present state of affairs as well as present to you my vision of the future: <strong>The Ultimate iOS Source Store</strong>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p><span id="more-3009"></span></p>
<p>So far I created and mailed about 100 invoices since end of January. That&#8217;s about 14 per month or 1 every other day, roughly. It does not feel as much because I have a fast and efficient process set up:</p>
<ol>
<li>If somebody has a question about how to order, I send them to my <a href="http://www.drobnik.com/touch/parts-store/#terms">terms and conditions</a> summary.</li>
<li>Once they e-mail me their order I add them to my Mac address book</li>
<li>I add them as a new client into <a href="http://www.marketcircle.com/billings/">Billings</a>. (For EU customers I add the VAT ID number and &#8220;Reverse Charge&#8221; in the comments so that this get printed on the invoice as well)</li>
<li>I create a new project &#8220;Dr. Touch&#8217;s Parts Store&#8221; and add the ordered products from my blueprints</li>
<li>The invoice is mailed as PDF to the client, bcc&#8217;ed to my CFO and accountant.</li>
<li>Then I await payment either via bank transfer or PayPal.</li>
<li>Finally, after payment is secure, I mail a &#8220;Quick Start&#8221; e-mail to the client explaining how to access the Subversion repository and how to take the first steps integrating the purchased component.</li>
</ol>
<p>This looks like much, but since this process only takes a couple of seconds every time I would never have guessed that it have been so many already. And I didn&#8217;t have any complaints so far, some customers apparently appreciate how I structure my components and are happy to return for more.</p>
<p>Billings is great for invoicing and tracking billable time, but I could not find any better way to get the invoice sums out of it to make a chart but to add them manually with my <a href="http://tapbots.com/software/calcbot/">Calcbot</a>.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-31-at-06.22.33.png"><img class="alignnone size-full wp-image-3010" title="Component Sales" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-31-at-06.22.33.png" alt="" width="370" height="413" /></a></p>
<p>Please forgive how this looks, I made a conscious effort to use Numbers and not Excel for this. But you can see that component invoices alone made on average 2000 Euros. This equals to <a href="http://www.google.com/search?client=safari&amp;rls=en&amp;q=2000+eur+in+usd&amp;ie=UTF-8&amp;oe=UTF-8">about 2500 US Dollars</a>. I intentionally decided on Euro as invoicing currency because a) it&#8217;s more convenient for me being in the Euro-Zone and b) PayPal converts it like a champ.</p>
<p>I find that due to the diversity of iOS developers and the diversity of apps they are making you have to have a wide selection of different things in your store because you cannot hope to match people&#8217;s current taste consistently with just one component. Sufficient diversity causes the above demonstrated consistency.</p>
<p>I have even more unreleased components up my sleeve that I am developing at the side. You know whenever I find myself creating something I stop and think if it would be of future value to me in a different project. And if the answer is yes or maybe then I prefix the class with DT (for Dr. Touch) and code it extra clean and extensible. This causes two things to occur: 1) my code is even cleaner more easier to maintain down the road and 2) with a bit of polishing and marketing I have a new component to sell.</p>
<h2>The Present</h2>
<p>At the moment that&#8217;s the way how it&#8217;s working for me. I&#8217;m quite busy with a big contracting project that at the same time builds up some Intellectual Property that I will be licensing exclusively to a US-based partner. So I&#8217;m certainly busy to an extent, that I have to pass on many contracts. Whenever I have some breathing space I&#8217;ll go into my tool chest and take up new components for my store, besides performing some long overdue overhauling of <a href="http://www.drobnik.com/touch/our-apps/">my own apps</a>.</p>
<p>I have to admit, that I am not the original inventor of the idea of selling source code or libraries. There&#8217;s a myriad of such sites that sell PHP, JavaScript and other code. The first company I found selling something for iOS developers is Plausible Labs. They are selling a <a href="http://plausiblelabs.com/code/pljukebox/">CoverFlow implementation</a>, pre-compiled from $300 (indie license) up to $2500 for the source code. If you are a serious about app development that you probably make more than the $10000 which is the limit where you can no longer get the indie license but need to shell out $900 for the &#8220;standard license&#8221;.</p>
<p>I always felt these prices to be something over the top, so I&#8217;m setting mine in the range of 100 to 400 Euros based on how much work I have to invest. But hey, let me be honest, I just don&#8217;t have the balls (yet) to charge what other people are charging. Plausible labs charges $150 for contracting, my maximum rate is $75 per hour. Maybe next year.</p>
<p>But I&#8217;m not the only one who is selling components. Only recently I have been approached by several people who are trying it as well.</p>
<ul>
<li>Tarek Sakr is offering <a href="http://www.sensiblecocoa.com/">Sensible Tableview</a>, making creation of tableview-based apps a breeze. Use promo code <span style="font-family: 'Lucida Grande';">SCSTVOD6210</span> to get a discount. Get it while the starting price is only $30!</li>
<li>iCodeSource offers <a href="http://www.icodesource.com/#tools">URL Manager</a> for $199 (single seat), $499 (5 seat) or $999 (25 seat) license.</li>
<li><a href="http://www.redlaser.com/Pricing.aspx">Red Laser barcode reading library</a> (no source), $2500 minimum license for free apps, then 10 cents per user in several tiers.</li>
<li>Brian Stormont (Stormy Productions) sells the <a href="http://stormyprods.com/products/radiokit.php">RadioKit SDK</a>, allowing you to make a streaming radio app. $100 per unique app.</li>
<li>The game <a href="http://www.sapusmedia.com/sources/">Sapus Tongue is available as source code</a> from $199 (&#8220;Basic&#8221;), $249 (with updates for 6 months) and $349 (&#8220;Premium&#8221;, allowing you to ask questions)</li>
</ul>
<p>Even Cocoa Superstar Matt Legend Gemmell is thinking aloud on how to do it right, <a href="http://mattgemmell.com/2010/03/14/selling-source-code">selling source code</a>. Although many people are glad that he doesn&#8217;t charge for his source so far, especially <a href="http://mattgemmell.com/2008/02/22/mgtwitterengine-twitter-from-cocoa">MGTwitterEngine</a> which powers quite a few iPhone twitter clients.</p>
<p>So we see that there is a need which more and more devs are trying to fill it. There&#8217;s a wide spectrum between free and ruinous. Personally I believe that my approach to be the one the balances income and liberties for the customers the best. If I had an online system that would manage pricing tiers for me then I might be tempted to also go with tiers from no-source-cheap all the way up to full-source-lifetime-support.</p>
<p>The market for iOS source software is in it&#8217;s infancy and more and more developers will find that selling components can supplement their income to a level where it might be sufficient to &#8220;do it fulltime&#8221;. Please bare with me as I lay out my vision on how it could be done in a smarter and more profitable way.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<h2><strong>The Future</strong></h2>
<p>What I really would like to achieve mid-term is to get a business going where several developers offer their components in on standardized online way for people to see demos, maybe get a time limited static library to try and then purchase access to an svn repository where they can always get the latest version of the components they purchased.</p>
<p>Possibly multiple pricing tiers: cheapest is a one off static library, middle is source code access and most expensive is with personal integration support. There might be an option for customers to subscribe so that you get a credit every month that you can spend on a product or service or save for something that needs more credits.</p>
<p>Having (almost) all of your heart&#8217;s desires represented in a single store has several advantages:</p>
<ul>
<li>developers can concentrate on what they love: write great code and get money for it.</li>
<li>customers can browse and are tempted to buy more</li>
<li>representing a large share of the market there can be common marketing activities that will benefit all participants.</li>
<li>Other people would be taking on all the hassles of account management, hosting, support etc.</li>
<li>by bringing together developers of multiple calibers in one location multiple synergies become possible: we could have a suggestion box where people interested in specific components could suggest and vote on them and then one or more developers could set out to make them, sort of like a &#8220;Part Kickstarter&#8221;.</li>
</ul>
<p>Also the owners of this business would vet other developer&#8217;s components for possible inclusion into this system. We would take a commission, say 30%, from those sales. Additionally a shared blog and advertisement revenues are thinkable.</p>
<p>This would need to be founded, funded, stocked and run as a real business. To succeed the goal would be to make this the only site people think of then wanting to save time purchasing a component instead of building it. There are sites out there that are doing that for WordPress templates and PHP or Javascript code, but I don&#8217;t think that this exists for Cocoa Touch yet.</p>
<p>Don&#8217;t know about funding yet, but I believe for this to work it has to been done professionally, with one or two people taking care of the administrative tasks and creating/running the website. And also doing marketing. This means there need to be sufficient funds to pay for hosting and manpower for at least half a year.</p>
<p>There are several levels to enter into this:</p>
<ul>
<li><strong>founder</strong>, brings funds, receives share in business and profit in relation to percentage of founding capital</li>
<li><strong>admin</strong>, gets paid for his parttime or fulltime work creating and running the business</li>
<li><strong>dev</strong>, brings his components to the table. Receives 70% of sales</li>
</ul>
<p>Forgive me if this sounds like a brain dump, because it is! I have no management training and I have founded and I am playing my iOS business &#8220;by ear&#8221;. So if you have something to contribute to this cause or would like to help me get this baby on it&#8217;s wheels then <a href="mailto:oliver@drobnik.com">contact me</a>.</p>
<p>UPDATE: I created a private <a href="http://groups.google.com/group/ultimate-ios-source-store">Google Group</a> so that the many people who are interested in participating have a somewhat more private forum to speak their mind.</p>
<div>I have invited people of these kinds to the group for I think their input will be invaluable.</div>
<div>
<ul>
<li>Developers I have partnered with in the past or have ongoing cooperations with where I share revenue with them</li>
<li>Developers who just have begun selling their components via their own website or are about to</li>
<li>Investors who have expressed interest in sharing in the founding of the endeavor</li>
<li>Entrepreneurs in general who can share experiences in how to project, develop and run such an endeavor.</li>
</ul>
<div>If this is you, or you know somebody to fit into one or more of these categories, please send them to us.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/08/building-the-ultimate-ios-source-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dr. Touch #020 – “Summer Pause”</title>
		<link>http://www.drobnik.com/touch/2010/08/dr-touch-020/</link>
		<comments>http://www.drobnik.com/touch/2010/08/dr-touch-020/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 19:58:46 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Podcast]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=3002</guid>
		<description><![CDATA[Between Apple event's it's back to looking for interest [...]]]></description>
			<content:encoded><![CDATA[<p>Between Apple event&#8217;s it&#8217;s back to looking for interesting rumors out of Cupertino. And my guest on this show is Ken Seto who made <a href="http://blog.endloop.ca/blog/2010/08/12/100k-in-4-months-a-niche-apps-path-to-app-store-success/">$100000 in 4 months</a> with <a href="http://itunes.apple.com/at/app/imockups-for-ipad/id364885913?mt=8">iMockups for iPad</a>.</p>

<p>The Show Notes and script after the break.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p><span id="more-3002"></span></p>
<h3>News</h3>
<p>Apple has begun testing three new devices as can be seen if you <a href="http://www.appleinsider.com/articles/10/08/16/ios_4_purportedly_references_cdma_iphone_4_next_gen_ipad.html">disassemble</a> the latest BETA of the 4.1 SDK. Apparently new devices cannot be activated via the iTunes production server and so Apple apparently has a short cut for certain device strings to skip activation altogether. The three devices are two minor updates to the current iPhone 4. Likely one of the iPhones will be a CDMA version that Apple bitterly needs to catch up to Android on the US carrier Verizon. Pundits are pretty certain about that it will be CDMA. But they are less sure of what variant the third iPhone 4 will be. Maybe 4G, also called LTE which stands for long term evolution. Another theory that I have is that it might be like an iPhone 4GS, with a Near Field Communication antenna.</p>
<p>Now the third device uses the same code as the iPad and judging from the version number it would be version 2 of the iPad. There is talk of a possible 7&#8243; iPad, but I don&#8217;t really think that Apple would want to dilute their brand like this. It&#8217;s more likely that the current iPad will become the cheapo version at like 200 dollars and the iPad 2.0 will be the latest and greatest. And iPad with a Retina Display would really be something, but to pull this off the graphics power would have to be quadrupled.</p>
<p>So when will we see these devices hit the market? Sources tell us that in the past new device ids always appeared about half a year before launch. So if I&#8217;m calculating correctly that would be end of January, or put differently: Q1 2011. Can&#8217;t be wrong with that prediction.</p>
<p><a href="http://tech.fortune.cnn.com/2010/08/02/with-ipad-apple-is-no-3-in-portables/">Deutsche Bank released</a> a report that compares the global portable computing market share. This report holds two very interesting facts for us.</p>
<p>One, the iPad apparently cannibalizes other manufacturer&#8217;s netbook and notebook sales. They where growing steadily for at least the year prior to the iPad&#8217;s launch. But when the iPad got released in Q1 2010 you can see all lines bending downwards. Except MacBooks which took off and crossed Acer to become number two in notebook market share.</p>
<p>Two, if you add the sales of iPad to the category it turns out that Apple is number one in mobile computing year-over-year unit growth. That&#8217;s units, the number of devices sold, not the money being made. But as usual a good info to know that you are betting on the right horse.</p>
<p>Big names Capcom and Bioware are reported to be &#8220;<a href="http://www.tuaw.com/2010/08/02/capcom-and-bioware-disappointed-in-iphone-app-performance/">disappointed&#8221; in their app store income</a>. Well what do they expect? Their experiments on the platform are not really innovative, reviews for their games are <a href="http://www.tuaw.com/2009/06/04/tuaw-at-e3-mass-effect-galaxy-on-the-iphone/">lukewarm</a>. While it is true that a couple of companies like Gameloft are taking home the biggest portion of the app store pie, small companies like Rovio show us that a new experience that plays to the unique strengths of the platform can be extremely successful. Actually today I have somebody on the show who is living proof of this.</p>
<p>Apple <a href="http://developer.apple.com/iphone/news/archives/2010/july/#applicationloader">revamped iTunes Connect</a>, specifically the app management pages. When they did that they also disabled the previous method of uploading apps. From now on you need to download and use a Mac app for that, the Application Loader which is available for free from the website. Basically you set up your app&#8217;s marketing materials and then when you are ready to upload you start the loader, select the app in the list box and choose the zip file to upload.</p>
<p>After there have been a lot of complaints about lacking security for iTunes accounts Apple has silently <a href="http://www.benm.at/2010/07/29/apple-verbessert-die-sicherheit-im-app-store/">introduced</a> a new security feature. If you are accessing the iTunes account from a new device you have to re-verify your payment info. This should make it less possible to create a multitude of accounts with the same credit card.</p>
<p>For devices running iOS 1.1.3 up to 3.1 Apple <a href="http://www.macrumors.com/c.php?u=http%3A%2F%2Ftechcrunch.com%2F2010%2F07%2F29%2Fapple-location%2F&amp;t=1282296949">relied on Skyhook Wireless</a> to locate uses in the absence of GPS data. In a response to federal legislators Apple revealed that starting with 3.2 and above OS versions they moved to their own database. Apple tries to build their own asssets in the mapping and location services arena, maybe to become less dependent on Google. They purchased Placebase about a year ago and last month they acquired small Canadian mapping firm Poly9.</p>
<p>After lots of <a href="http://www.macrumors.com/2010/07/28/apple-squashing-ipad-magazine-subscription-plans/">haggling</a> Apple finally reached an agreement with sellers of paper-based magazine subscriptions. The argument was about Apple insisting on their cut of 30% from apps, whereas magazines wanted to sell bundle subscriptions that would allow them to charge the users directly and have a free app to access their subscribed content. Apparently this <a href="http://tech.fortune.cnn.com/2010/08/19/time-inc-breaks-the-ipad-logjam/?utm_source=twitterfeed&amp;utm_medium=twitter">has been worked out</a>, or rather Apple seems to have given in. People magazine will be the first publication by Time, Inc. to follow this model.</p>
<p>With the new release of the operating system 4.0 we developers got a great deal of new toys to play with. One question we keep asking ourselves is: when do we reach the point that it makes business sense to release an app that requires 4.0 and above? Well, we&#8217;re coming close to the tipping point. <a href="http://www.appleinsider.com/articles/10/07/22/chitika_ios_4_already_powering_50_of_iphone_traffic.html">According to Chitika</a>, who sampled 9 Million page views on their network, 4.0 has surpassed an adoption of 50% at the end of July. If you take into consideration that it had only been launched about a month before that&#8217;s an amazing adoption rate.</p>
<p>If this keeps up then I would say you can already plan your next iPhone-only app in 4.0. Only if you want to go hybrid then you are still stuck with 3.2 as 4.0 remains notably absent for iPad. I hope they merge the versions back again real soon, because this is kind of a pain.</p>
<p>Google claims to be activating 200,000 Android handsets every day, but <a href="http://www.tuaw.com/2010/07/05/pair-of-app-store-studies-show-apple-is-the-devs-choice-for-no/">two studies</a> show that the app store is still the choice for the majority of mobile developers. Beginning of June there have been around 43,000 iOS developers and around 10,000 Android developers, with 1,400 being cross-platform. The growth of Android must be a bit of a headache for Apple since it&#8217;s obviously their lock-in with AT&amp;T that&#8217;s costing them lots of growth in the US. And I know from experience here in our small country of Austria that the exclusive contracts with number 2 and 3 of our cellular providers leaves number one, Mobilkom, in the rain selling Android and Blackberry instead.</p>
<p>Tbere are other reasons why people, like myself, prefer the iOS platform. On the android marketplace you don&#8217;t have a possbility to charge for apps in the majority of markets. It&#8217;s not like with the app store where you can sell apps in every country that has been opened. And also the customer mentality with Android handsets is &#8220;it&#8217;s free, it&#8217;s me. Me pay, no way!&#8221;.</p>
<p>And the funniest bit of news came last week: Oracle is suing Google to &#8220;impound and destroy&#8221; Android, or more precisely everything that infringens on Oracle&#8217;s rights in Java. Google had hoped to get around all licensing by creating their own Java implementation and compiler, but in Oracle&#8217;s opinion that still means they are using ideas Oracle owns. Owns because they purchased them in the form of Sun earlier this year. Pundits smile and suggest that Steve Jobs and Oracle CEO Larry Elison are close friends, so Larry is doing Steve a big favor. It&#8217;s suspected that some companies might distance themselves from Android while the outcome of the lawsuit is open. Investing in Android is something of a business risk at the moment. Good for us Apple fanboys.</p>
<h3>Interview</h3>
<p>I&#8217;m talking with Ken Seto who together with his brother made $100,000 with <a href="http://itunes.apple.com/at/app/imockups-for-ipad/id364885913?mt=8">iMockups for iPad</a>. How did he do it? What advice does he has for us?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/08/dr-touch-020/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://www.drobnik.com/audio/Dr_Touch_020.mp3" length="34502018" type="audio/mpeg" />
		</item>
		<item>
		<title>Reachability</title>
		<link>http://www.drobnik.com/touch/2010/08/reachability/</link>
		<comments>http://www.drobnik.com/touch/2010/08/reachability/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 15:09:58 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Recipes]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=2993</guid>
		<description><![CDATA[If your app requires an internet connection for certain [...]]]></description>
			<content:encoded><![CDATA[<p>If your app requires an internet connection for certain tasks you will have to be able to deal with situations where connectivity drops out for some time. For many cases it might be sufficient to display an error when stringWithContentsOfURL returns nil, but it&#8217;s better customer service to inform the user beforehand. Apple thinks so too, they test all apps also in airplane mode and your app better not crash or confuse the user or else it will get rejected.</p>
<p><img class="alignnone size-full wp-image-2995" title="No Reachability inside" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-17-at-3.41.04-PM.png" alt="" width="285" height="208" /></p>
<p>Fortunately there is a great sample on the Apple Website that you might have heard it&#8217;s name mentioned in many circles: <a href="http://developer.apple.com/iphone/library/samplecode/Reachability/">Reachability</a>. The first version of this was difficult to use but Apple staff keeps polishing their works and so we have reached version 2.2 already, recently updated for iOS 4. The major change that 2.x gave us is the ability to get continuous updates on connection availability. This enables us to have our apps work similar to the iTunes app which displays a message to this effect when there&#8217;s no connection and has the UI return as soon as the connection is back.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/iTunes_no_internet.jpg"><img class="alignnone size-full wp-image-2994" title="iTunes no internet" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/iTunes_no_internet.jpg" alt="" width="320" height="480" /></a></p>
<p>So, let&#8217;s explore how to add the source for Reachability to our project and have some live checks.</p>
<p><span id="more-2993"></span></p>
<p>First you need to download the latest version of the sample source from the developer website. Here&#8217;s the <a href="http://developer.apple.com/iphone/library/samplecode/Reachability/">direct link</a>. Click on the &#8220;Download Sample Code&#8221; button to retrieve the ZIP file.</p>
<p>If you open the sample project you might get &#8220;Base SDK missing&#8221; if you&#8217;re using the latest Xcode and SDK beta. Just switch it to one that you have, by going Project &#8211; Edit Project Settings &#8211; Base SDK. I use 4.1 at the time of this writing.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>From the sample project you need Reachability.h and .m, copy them over to your project. The Reachability class actually wraps up functionality available in the SystemConfiguration.framework and so you need to add a reference to that as well.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-17-at-3.53.36-PM.png"><img class="alignnone size-full wp-image-2996" title="File structure with necessary things from sample project" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-17-at-3.53.36-PM.png" alt="" width="269" height="274" /></a></p>
<p>There are two ways how you can make use of the Reachability class. The synchronous mode lets you query for the current state, the asynchronous mode sends notifications. Usually you&#8217;d want a hybrid solution, because you want a view to look correct for the current network state when it appears as well as react to subsequent changes in reachability. Every instance of Reachability is initialized with a host name that you want to be able to reach.</p>
<p>You can have several running at the same time if your app requires connectivity to seperate hosts. It&#8217;s up to you to decide how likely the second host will not be reachable if the first one isn&#8217;t. Reachability tests if the host name can be resolved and if there is a TCP/IP path that allows to reach the host. It does not check for the availability of certain web pages. So in all likelyhood you get by with just a single Reachability instance. That&#8217;s because not reaching one host usually means that the iPhone does not have internet connectivity.</p>
<p>Here&#8217;s the code to demonstrate the use within a view controller:</p>

<div class="wp_codebox"><table><tr id="p29935"><td class="code" id="p2993code5"><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>configureForNetworkStatus<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NetworkStatus<span style="color: #002200;">&#41;</span>status
<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// do something with status</span>
	<span style="color: #a61390;">switch</span> <span style="color: #002200;">&#40;</span>status<span style="color: #002200;">&#41;</span> 
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">case</span> NotReachable<span style="color: #002200;">:</span>
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Not Reachable&quot;</span><span style="color: #002200;">&#41;</span>;
			<span style="color: #a61390;">break</span>;
		<span style="color: #a61390;">case</span> ReachableViaWiFi<span style="color: #002200;">:</span>
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Reachable via WiFi&quot;</span><span style="color: #002200;">&#41;</span>;
			<span style="color: #a61390;">break</span>;
		<span style="color: #a61390;">case</span> ReachableViaWWAN<span style="color: #002200;">:</span>
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Reachable via WWAN&quot;</span><span style="color: #002200;">&#41;</span>;
			<span style="color: #a61390;">break</span>;
		<span style="color: #a61390;">default</span><span style="color: #002200;">:</span>
			<span style="color: #a61390;">break</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>awakeFromNib
<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// subscribe to notification</span>
	<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/"><span style="color: #400080;">NSNotificationCenter</span></a> defaultCenter<span style="color: #002200;">&#93;</span> addObserver<span style="color: #002200;">:</span> self 
		selector<span style="color: #002200;">:</span> <span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>reachabilityChanged<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> 
		name<span style="color: #002200;">:</span> kReachabilityChangedNotification object<span style="color: #002200;">:</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// init one watcher, instance variable</span>
	siteReachability <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>Reachability reachabilityWithHostName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;www.apple.com&quot;</span><span style="color: #002200;">&#93;</span>
		 retain<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// get first status</span>
	NetworkStatus siteNetworkStatus <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>siteReachability currentReachabilityStatus<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// do something with it</span>
	<span style="color: #002200;">&#91;</span>self configureForNetworkStatus<span style="color: #002200;">:</span>siteNetworkStatus<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// start continous updates</span>
	<span style="color: #002200;">&#91;</span>siteReachability startNotifier<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>dealloc 
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/"><span style="color: #400080;">NSNotificationCenter</span></a> defaultCenter<span style="color: #002200;">&#93;</span> removeObserver<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>siteReachability release<span style="color: #002200;">&#93;</span>;  <span style="color: #11740a; font-style: italic;">// also stops notifier</span>
    <span style="color: #002200;">&#91;</span>super dealloc<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> reachabilityChanged<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSNotification_Class/"><span style="color: #400080;">NSNotification</span></a><span style="color: #002200;">*</span> <span style="color: #002200;">&#41;</span>note
<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// get Reachability instance from notification</span>
	Reachability<span style="color: #002200;">*</span> curReach <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>note object<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// assert that we actually got Reachability instance</span>
	NSParameterAssert<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>curReach isKindOfClass<span style="color: #002200;">:</span> <span style="color: #002200;">&#91;</span>Reachability class<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// get current status</span>
	NetworkStatus siteNetworkStatus <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>curReach currentReachabilityStatus<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// do something with it</span>
	<span style="color: #002200;">&#91;</span>self configureForNetworkStatus<span style="color: #002200;">:</span>siteNetworkStatus<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>In this sample I&#8217;m initializing everything in the awakeFromNib because I&#8217;m getting my view controller from a XIB file.</p>
<p>The code shows how to query a fresh instance for the current status. Then it starts the notifier which will send an NSNotification as soon as the connectivity state changes. As you can see there are three different values to NetworkStatus: no connection at all, site reachable via WiFi, site reachable via WWAN (= cellular data). So you could react differently if you know a big pipe is available as opposed to cellular where people might have limited bandwidth or volume.</p>
<p>Checking for reachability of a specific host is the most practical use case of Reachability. In much rarer cases you might want to check for availability of local WiFi or the internet in general (if you don&#8217;t need to access a specific host). Specialized initializers are available for these cases, check the header if you need these.</p>
<p>Enabling your apps for reachability checking is easier than ever. The most difficult part now is to design a nice screen, message or graphic to tell the user that he has to wait until he&#8217;s out of the tunnel.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/08/reachability/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iPhone 4 Tripod Mount Shootout</title>
		<link>http://www.drobnik.com/touch/2010/08/iphone-4-tripod-mount-shootout/</link>
		<comments>http://www.drobnik.com/touch/2010/08/iphone-4-tripod-mount-shootout/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 12:30:54 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=2983</guid>
		<description><![CDATA[If you're like me then you justified getting an iPhone  [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re like me then you justified getting an iPhone 4 (on top of the original 2G, 3G and 3GS) by telling your wife &#8220;honey, this has an HD camcorder BUILT IN. By getting this we actually SAVE the money for an extra device.&#8221; And then on the second or third video you&#8217;re shooting you&#8217;ll find that you have the hands of a programmer and not of a surgeon. Meaning that it is next to impossible holding the iPhone perfectly steady.</p>
<p>Yet once more we see that technology has advanced to a level where it is no longer the limiting factor, but instead the human body is. For all intents and purposes of my iPhone business I deem the quality of the iPhone 4 video recorder more then sufficient. If only there was something that would help me steady my aim and frame. Well, there is, because this problem is one that photographers and videographers have been having for a long time. And most of the solutions revolve around contraptions that allow you to levitate your lens in a fixed distance from the floor.</p>
<p>I am of course talking about the tripod. You might remember from geometry that any surface can be described by 3 points. Tripods define a point by three feet. The point where you can mount a camera usually has two or three degrees of freedom which you an restrict by tightening screws. One or two of these screws might be attached to a handle that would allow you to move the tripod head around and adjust the tightness of one scree by turning your wrist.</p>
<p>I shopped around for a 3-way tripod to mount my iPhone 4 on and ended picking the <a href="http://www.amazon.com/gp/product/B0029LHW2M?ie=UTF8&amp;tag=wwwdrobnikcom-21&amp;linkCode=as2&amp;camp=1638&amp;creative=6742&amp;creativeASIN=B0029LHW2M">Cullmann Nanomax 250</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.de/e/ir?t=wwwdrobnikcom-21&amp;l=as2&amp;o=3&amp;a=B0029LHW2M" border="0" alt="" width="1" height="1" /> which is a sturdy but extremely lightweight tripod that almost fits into my backback. Because it is made out of aluminum it weighs only 2.3 lbs (1 kg). So it&#8217;s ideally light and compact to work for a blogging developer like myself. <a href="www.cullmann-foto.de">Cullmann</a> in Germany grants you 10 year warranty on the tripod if you register on their website.</p>
<p>But this article is not about my choice of tripod. Once you got one you are presented with the challenge to somehow mount your pretty iPhone on it. That&#8217;s where special cam mounts are necessary. I asked around on Twitter and two options were recommended to me. I purchased both and now I&#8217;m going to compare them so that you don&#8217;t have to.</p>
<p><span id="more-2983"></span></p>
<h3>Mosy Mount</h3>
<p>When I received the <a href="http://www.mosymount.com">Mosy Mount</a> package they made it as much an Apple experience as possible. You receive a metal box with a clear window at the top that presents the mount. Or rather, A mount, because inside the box you find another one to make TWO mounts for the price of one. One is already attached to a clear case that fits the iPhone 4&#8242;s rectangular frame. The other is affixed to a temporary piece of cardboard with instructions on how to mount this on your own case. Disclaimer: nothing sticks to silicone. You also get a foldable mini-tripod for use on tables.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Mosy_Solo.jpg"><img class="alignnone size-full wp-image-2984" title="Mosy Mount without iPhone" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Mosy_Solo.jpg" alt="" width="614" height="459" /></a></p>
<p>You have a choice of three motives that all are basically a rectangular foamy plastic piece with an embedded 1/4&#8243; screw. Once the iPhone is in the case there is no chance in hell that it can fall out, removing the case takes a bit of fiddling which is a good thing if you worry about that. A bad thing if you are impatient and are not planning to use it on rough rides. Through the Mosy Mount the mounting screw is placed near the center of gravity on the back of the iPhone. This is the reason why out of the box you require a 3-way head on your tripod. With 2-ways all you can hope to film is the heavens.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Mosy_Action.jpg"><img class="alignnone size-full wp-image-2985" title="Mosy Mount in Action" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Mosy_Action.jpg" alt="" width="614" height="461" /></a></p>
<p>With the 3-way head of my tripod I can have the camera point at a target with the handling sicking out to the right side. That&#8217;s fine for shots that don&#8217;t require an up and down movement. Horizontal panning and steady shots work perfectly if that&#8217;s all you require. When I ranted on Twitter about this the maker of Mosy Mount contacted me and sent me a list of materials plus plan on how to to convert the Mosy Mount with an right angle bracket. He&#8217;s a very friendly guy, an incredibly personal level of support. He warned me not to tighten the mount screw too much or else I would pull out the metal piece of the mold.</p>
<p>The clear case tightly grips the sharp edge of your iPhone 4. The 3D mold is a piece of art but it has a bit of a drawback. The surface is not flat and thus you don&#8217;t quite feel how much you can tighten the screw. Also it does not feel like there is a good contact which still permits a bit of rotation around the screen. That&#8217;s another con. You might feel that your iPhone is safe in the case when mounting it onto a moving vehicle, but you should take extra precautions because of this weak spot.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<h3>U+G4 Holder</h3>
<p>I found the website for the U+G4 holder even before Mosy Mount because they are more SEO-savvy: <a href="http://www.iphone-tripodholder.com">www.iphone-tripodholder.com</a>. My first impression was to think that the screw is on the wrong place, namely on the small side. Wouldn&#8217;t that mean I can only shoot portrait video?</p>
<p>I received the holder without any trimmings in a padded envelope. But what the packaging understates the holder itself talks all the more loudly. You find the holder to be made out of strong plastic with a professional screw embedded in the smaller side and 2 small 3M <a href="http://products3.3m.com/catalog/us/en001/manufacturing_industry/specialty_tapes/node_GSB3H1YJ8Rbe/root_GST1T4S9TCgv/vroot_GSNYTMLW46ge/gvel_GSSLRYMDZXgl/theme_us_specialtytapes_3_0/command_AbcPageHandler/output_html">Bumpon</a> pads to keep the iPhone from sliding out once you moved it into place. You can slide the iPhone in both ways due to a small window in the mount, a sort of rail fits the device perfectly.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/UG4_Solo.jpg"><img class="alignnone size-full wp-image-2986" title="U+G4 without iPhone" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/UG4_Solo.jpg" alt="" width="614" height="459" /></a></p>
<p>The bottom of the mount is flat to allow for good fastening of the mounting plate which is standard with all modern tripods. It&#8217;s a plastic rectangle that you screw onto the 1/4&#8243; thingy which itself can be fastened to the tripod by a simple lever. You feel that some thought went into this method, enough to be pending a patent.</p>
<p>Having the mounting screw at the side allows for the tripod handle to be where it should be: in the opposite direction of the lens. Mounted like this you can pan vertical and sideways with ease. In this case tightening the handle will restrict the up/down motion. It&#8217;s logical and intuitive this way which makes this mount my favorite for any kind of moving targets.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/UG4_Action.jpg"><img class="alignnone size-full wp-image-2987" title="U+G4 in Action" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/UG4_Action.jpg" alt="" width="614" height="461" /></a></p>
<p>What remains to be seen is how the life of the pads will go. That&#8217;s only something that repeated use of a longer time span can show us. If you&#8217;re planning to use the U+G4 on a moving vehicle you might want to add an additional rubber band to secure your phone into the mount. While it stays inside against gravity a short jerky movement can move it out of its secure position inch by inch.</p>
<h3>Conclusion</h3>
<p>For both cases you will need to remove any Bumper or other case you might have to fit. The Mosy Mount itself is a case that will protect your phone a bit, at least from scratching and it comes with the benefit of letting you transform a protective case of your choice into a mount (as long it&#8217;s not silicone). The U+4G is way less artsy, straight to the point and gives me more confidence in the screwing. Also it costs half as much as the competitor.</p>
<p>After having evaluated both mounts for some time in direct comparison I formed my opinion. Personally I prefer the U+4G over the Mosy Mount because of the more logical way of &#8220;steering&#8221; via the handle and because of the tighter fit with my tripod mounting plate. You might have noticed that I have a red sticker around the edges of my iPhone (by <a href="http://www.blue-mac.net/">:blueMac</a>) to protect it until I get my official bumper. The Mosy case threatens the life of this sticker because of how tightly it hugs the device.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>My summary of the pros and cons of both mounts follows below.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Both_Holders.jpg"><img class="alignnone size-full wp-image-2988" title="Both Holders" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Both_Holders.jpg" alt="" width="614" height="461" /></a></p>
<p><strong>Mosy Mount</strong></p>
<p>Pro: Stylish, 3 Motives, two mounts let you convert your existing case, great personal support, foldable mini-tripod included</p>
<p>Con: area around screwing hole not flat, inconvenient mounting position for moving targets</p>
<p><a href="http://www.mosymount.com">$19.95 by Art4Media LLC</a></p>
<p><strong>U+G4</strong></p>
<p>Pro: Sturdy plastic, professional screwing hole, allows usage of &#8220;steering handle&#8221; in tripod, patent pending</p>
<p>Con: Open side might allow iPhone to shake out, not designed for protecting iPhone</p>
<p><a href="http://www.iphone-tripodholder.com/">$9.95 by G Design LLC</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/08/iphone-4-tripod-mount-shootout/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NavigationController from NIB produces sticky gray empty status bar on rotation</title>
		<link>http://www.drobnik.com/touch/2010/08/navigationcontroller-from-nib-produces-sticky-gray-empty-status-bar-on-rotation/</link>
		<comments>http://www.drobnik.com/touch/2010/08/navigationcontroller-from-nib-produces-sticky-gray-empty-status-bar-on-rotation/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 17:08:41 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Bug Reports]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=2974</guid>
		<description><![CDATA[I've decided that I'll share my bug reports on my blog  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided that I&#8217;ll share my bug reports on my blog from now on as well. Usually you&#8217;ll have to make a small demo project to demonstrate the bug to Apple&#8217;s engineers and then they are the only ones to see my work. What a waste.</p>
<p>I still believe that Apple&#8217;s Bug Reporting system should be open for everybody, but since Apple is still run like a small startup they feel that it helps them conserve more resources to have it closed. That&#8217;s why there is <a href="http://openradar.appspot.com">Open Radar</a> which somebody put on Google App Engine.</p>
<p>So, here&#8217;s my full bug report plus the demo project and screen shot. See if you can reproduce it and find a workaround.</p>
<hr />
<h3>NavigationController from NIB produces sticky gray empty status bar on rotation</h3>
<p>16-Aug-2010 06:40 PM Oliver Drobnik KG:<br />
Summary:</p>
<p>If you load a navigation controller from MainWindow.xib, but add the first view controller in appDidFinishLaunching, then there is a problem on rotation. A gray empty status bar appears underneath the regular status bar which cannot be eliminated.</p>
<p>Steps to Reproduce:</p>
<ul>
<li>Create a Navigation based project.</li>
<li>Set status bar to be initially hidden.</li>
<li>Set navigation controller to want full screen and have nav bar hidden</li>
<li>Implement a tap method in the view controller to hide and show the status bar</li>
<li>Move the view controller outside of the navigation controller in the IB</li>
<li>Add a line to app delegate to push the now separate view controller onto the navigation controller.</li>
<li>Start the app, rotate once sideways with shown status bar</li>
<li>tap to hide the status bar</li>
</ul>
<p>Expected Results:</p>
<p>No extra gray status bar.</p>
<p>Actual Results:</p>
<p>A sticky gray status bar appears underneath the disappearing regular status bar.</p>
<p>I&#8217;m attaching a project to demonstrate the behavior. Plus a screenshot.</p>
<p>The behavior is inconsistent with creating a navigation controller in code. There no extra status bar appears.</p>
<hr />
<h3>Discussion</h3>
<p>I <a href="http://openradar.appspot.com/radar?id=600401">filed this bug</a> report on Open Radar as well.<a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-16-at-6.41.50-PM.png"></a> Here&#8217;s the Project file I&#8217;m referencing: <a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/StatusBarBug.zip">StatusBarBug.zip</a></p>
<p>To see the bug for yourself launch the demo project in iPad Simulator. Tap the screen to show the black status bar. Then rotate the simulator once. Tap the screen again to hide the status bar. Behind it this gray bar appears.</p>
<p>This is how the screen looks like with the extraneous status bar showing.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-16-at-6.41.50-PM.png"><img class="alignnone size-medium wp-image-2976" title="Extra gray status bar after rotation" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-16-at-6.41.50-PM-300x232.png" alt="" width="300" height="232" /></a></p>
<p>Iif you set the navigation controller&#8217;s root view controller already in the NIB (as it&#8217;s usually the case) then this behavior does not occur. So for this demo I moved the view controller outside of the navigation controller.</p>
<p><a href="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-16-at-7.04.54-PM.png"><img class="alignnone size-full wp-image-2979" title="View Controller outside of Navigation Controller" src="http://www.drobnik.com/touch/wp-content/uploads/2010/08/Screen-shot-2010-08-16-at-7.04.54-PM.png" alt="" width="418" height="211" /></a></p>
<p>If you don&#8217;t instantiate the navigation controller via a NIB file, but instead put the following code into the applicationDidFinishLaunching, then you will not see this extra bar.</p>

<div class="wp_codebox"><table><tr id="p29746"><td class="code" id="p2974code6"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>application<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIApplication <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>application didFinishLaunchingWithOptions<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>launchOptions
<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// could also initWithRootViewController, same effect</span>
&nbsp;
 	navController <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UINavigationController alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
	navController.wantsFullScreenLayout <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
	navController.navigationBar.hidden <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>navController pushViewController<span style="color: #002200;">:</span>viewController animated<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>window addSubview<span style="color: #002200;">:</span>navController.view<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>window makeKeyAndVisible<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>This leads me to the conclusion that something funny is happening when getting your navigation controller from a xib (without root view controller set) versus instantiating it in code. Which prompted me to file this bug. If you find that it is actually something that I am doing wrong here, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/08/navigationcontroller-from-nib-produces-sticky-gray-empty-status-bar-on-rotation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tap&amp;Hold for TableView Cells, Then and Now</title>
		<link>http://www.drobnik.com/touch/2010/08/taphold-for-tableview-cells-then-and-now/</link>
		<comments>http://www.drobnik.com/touch/2010/08/taphold-for-tableview-cells-then-and-now/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 16:06:33 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Recipes]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=2963</guid>
		<description><![CDATA[It was before SDK 3.2 that I developed a technique to a [...]]]></description>
			<content:encoded><![CDATA[<p>It was before SDK 3.2 that I developed a technique to add tap-and-hold interactivity to your tableview cells. In this article I&#8217;ll demonstrate the old technique, which still works, and contrast it with how much easier it has become if you can target iOS 3.2 and above.</p>
<p>First the &#8220;old way&#8221;. It needs to customize touch handling for the tableview cells themselves, which means you have to subclass UITableViewCell.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-1142183725909145";
google_ad_slot = "4110438702";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p><span id="more-2963"></span></p>
<p><strong>TouchAndHoldCell.h</strong></p>

<div class="wp_codebox"><table><tr id="p29637"><td class="code" id="p2963code7"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;UIKit/UIKit.h&gt;</span>
&nbsp;
<span style="color: #a61390;">@class</span> TouchAndHoldCell;
&nbsp;
<span style="color: #a61390;">@protocol</span> TouchAndHoldCellDelegate &lt;NSObject&gt;
@optional 
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>didTouchAndHoldForCell<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>TouchAndHoldCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>cell;
<span style="color: #a61390;">@end</span>
&nbsp;
<span style="color: #a61390;">@interface</span> TouchAndHoldCell <span style="color: #002200;">:</span> UITableViewCell 
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">id</span> &lt;TouchAndHoldCellDelegate&gt; delegate;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, assign<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">id</span> &lt;TouchAndHoldCellDelegate&gt; delegate;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<p><strong>TouchAndHoldCell.m</strong></p>

<div class="wp_codebox"><table><tr id="p29638"><td class="code" id="p2963code8"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;TouchAndHoldCell.h&quot;</span>
&nbsp;
&nbsp;
<span style="color: #a61390;">@implementation</span> TouchAndHoldCell
&nbsp;
<span style="color: #a61390;">@synthesize</span> delegate;
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithStyle<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableViewCellStyle<span style="color: #002200;">&#41;</span>style reuseIdentifier<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>reuseIdentifier 
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithStyle<span style="color: #002200;">:</span>style reuseIdentifier<span style="color: #002200;">:</span>reuseIdentifier<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        <span style="color: #11740a; font-style: italic;">// Initialization code</span>
    <span style="color: #002200;">&#125;</span>
    <span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>touchAndHold<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>params
<span style="color: #002200;">&#123;</span>
	<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a> <span style="color: #002200;">*</span>touches <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>params objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;touches&quot;</span><span style="color: #002200;">&#93;</span>;
	UIEvent <span style="color: #002200;">*</span>event <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>params objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;event&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>super touchesCancelled<span style="color: #002200;">:</span>touches withEvent<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>delegate <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#91;</span>delegate respondsToSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>didTouchAndHoldForCell<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</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>delegate didTouchAndHoldForCell<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>touchesBegan<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches withEvent<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event
<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// 1 second holding triggers touchAndHOld</span>
	<span style="color: #002200;">&#91;</span>self performSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>touchAndHold<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span> withObject<span style="color: #002200;">:</span>
		<span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/"><span style="color: #400080;">NSDictionary</span></a> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span>touches, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;touches&quot;</span>, event, <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;event&quot;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> afterDelay<span style="color: #002200;">:</span><span style="color: #2400d9;">0.5</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>super touchesBegan<span style="color: #002200;">:</span>touches withEvent<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>touchesMoved<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches withEvent<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> cancelPreviousPerformRequestsWithTarget<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;	
	<span style="color: #002200;">&#91;</span>super touchesMoved<span style="color: #002200;">:</span>touches withEvent<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>touchesEnded<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches withEvent<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> cancelPreviousPerformRequestsWithTarget<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;	
	<span style="color: #002200;">&#91;</span>super touchesEnded<span style="color: #002200;">:</span>touches withEvent<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>touchesCancelled<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/"><span style="color: #400080;">NSSet</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>touches withEvent<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIEvent <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>event
<span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/"><span style="color: #400080;">NSObject</span></a> cancelPreviousPerformRequestsWithTarget<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;	
	<span style="color: #002200;">&#91;</span>super touchesCancelled<span style="color: #002200;">:</span>touches withEvent<span style="color: #002200;">:</span>event<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>This works by calling a selector with half a second delay. If the finger is lifted before this expires the delayed call is cancelled. If it does get to expire then we have a long press and thus the cell can tell it&#8217;s delegate (the tableview controller) that a long press (that&#8217;s how Apple calls it) transpired.</p>
<p>To use this you would override the cellForRowAtIndexPath method and provide a method to react to the long press.</p>

<div class="wp_codebox"><table><tr id="p29639"><td class="code" id="p2963code9"><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><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath <span style="color: #002200;">&#123;</span>
&nbsp;
    <span style="color: #a61390;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>CellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cell&quot;</span>;
&nbsp;
    TouchAndHoldCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>TouchAndHoldCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>CellIdentifier<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><span style="color: #002200;">&#91;</span>TouchAndHoldCell alloc<span style="color: #002200;">&#93;</span> initWithStyle<span style="color: #002200;">:</span>UITableViewCellStyleDefault reuseIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
		cell.delegate <span style="color: #002200;">=</span> self;
    <span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">// Configure the cell.</span>
	cell.textLabel.text <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Text&quot;</span>;
    <span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #6e371a;">#pragma mark TouchAndHoldCell Delegate</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>didTouchAndHoldForCell<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>TouchAndHoldCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>cell
<span style="color: #002200;">&#123;</span>
	UIActionSheet <span style="color: #002200;">*</span>action <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIActionSheet alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Actions&quot;</span> delegate<span style="color: #002200;">:</span>self cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cancel&quot;</span> destructiveButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Destruct&quot;</span> otherButtonTitles<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>action showInView<span style="color: #002200;">:</span>self.view<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>action release<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>actionSheet<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIActionSheet <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>actionSheet didDismissWithButtonIndex<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>buttonIndex
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>buttonIndex<span style="color: #002200;">==</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Destruct&quot;</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">else</span>
	<span style="color: #002200;">&#123;</span>
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cancel&quot;</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>That&#8217;s the historic evidence of past ingenuity. Next we&#8217;re going to examine how that&#8217;s done today. Easier, faster, more Apple if you will.</p>
<p>iOS and SDK 3.2 gave us one of the most ingenious things that Apple could ever invent. For two years we had to code all our touch handling ourselves which resulted in a variety of different approaches, all with a different feel to them. Gesture Recognizers changed all that, 3.2 brought them first to the iPad and they are also part of iOS 4.x. Unfortunately they are not backwards compatible. </p>
<p>All it takes is to create such a gesture recognizer instance and attach it to the appropriate view.</p>

<div class="wp_codebox"><table><tr id="p296310"><td class="code" id="p2963code10"><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><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath 
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>CellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cell&quot;</span>;
&nbsp;
&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>CellIdentifier<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><span style="color: #002200;">&#91;</span>UITableViewCell alloc<span style="color: #002200;">&#93;</span> initWithStyle<span style="color: #002200;">:</span>UITableViewCellStyleDefault 
		reuseIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
&nbsp;
		UILongPressGestureRecognizer <span style="color: #002200;">*</span>longPressGesture <span style="color: #002200;">=</span> 
			<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UILongPressGestureRecognizer alloc<span style="color: #002200;">&#93;</span> 
			  initWithTarget<span style="color: #002200;">:</span>self action<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>longPress<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>cell addGestureRecognizer<span style="color: #002200;">:</span>longPressGesture<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #11740a; font-style: italic;">// Configure the cell.</span>
	cell.textLabel.text <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Text&quot;</span>;
    <span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>longPress<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UILongPressGestureRecognizer <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>gesture
<span style="color: #002200;">&#123;</span>
	<span style="color: #11740a; font-style: italic;">// only when gesture was recognized, not when ended</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>gesture.state <span style="color: #002200;">==</span> UIGestureRecognizerStateBegan<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #11740a; font-style: italic;">// get affected cell</span>
		UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>gesture view<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #11740a; font-style: italic;">// get indexPath of cell</span>
		<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/"><span style="color: #400080;">NSIndexPath</span></a> <span style="color: #002200;">*</span>indexPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self.tableView indexPathForCell<span style="color: #002200;">:</span>cell<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #11740a; font-style: italic;">// do something with this action</span>
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Long-pressed cell at row %d&quot;</span>, indexPath<span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>Gesture Recognizers employ the same methodology as we have seen before for adding target/actions to UIControls, for example UIButtons. The target is the instance of a class to receive the message, the action is the selector. And the parameter that&#8217;s being passed is the sender of the message. For UIControl events that&#8217;s the sending view, for UIGestureRecognizer events it&#8217;s the instance of the gesture recognizer you have set up.</p>
<p>In the above example we simply create a UILongPressGestureRecognizer (which has the appropriate expiration time interval already built in) and attach it to each cell we create. If the tableview is long enough so that we get to recycle cells it would still work, because we don&#8217;t care which cell a recognizer is attached to, as long as there is one for each cell you can tap on, recycled or new.</p>
<p>In the longPress: method we can query the tableView for the &#8220;line&#8221; we tapped on. For a while I was setting the cell&#8217;s tag value to the number of the row, but I found that this ceases to work if you allow for deletion of rows, because then the indexes you put into the tags have incorrect values. Better to ask the tableView itself at time of the pushing via the conveneient indexPathForCell method.</p>
<p>Also note that this method is being called twice, namely when the gesture is recognized (when the finger was on the cell long enough) and when it&#8217;s ended (when you lift the finger). Usually you&#8217;ll want to only react when it&#8217;s started.</p>
<p>You see, that gesture recognizers really reduce the amount of code we need to write to achieve some advanced touch handling.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/08/taphold-for-tableview-cells-then-and-now/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MyAppSales for Partners</title>
		<link>http://www.drobnik.com/touch/2010/08/myappsales-for-partners/</link>
		<comments>http://www.drobnik.com/touch/2010/08/myappsales-for-partners/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 14:30:32 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Updates]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=2956</guid>
		<description><![CDATA[A user of MyAppSales approached me and asked for the po [...]]]></description>
			<content:encoded><![CDATA[<p>A user of MyAppSales approached me and asked for the possibility to pre-configure the app such that he could give it to a partner of his. The goal was twofold:</p>
<ol>
<li>Pre-configure the account for iTunes Connect such that you don&#8217;t have to give your credentials to your partner</li>
<li>Filter sales reports such that only the apps come through that the partner is receiving a share of sales for</li>
</ol>
<p>&#8230; and all of this without impacting the other features like review downloading.</p>
<p>Since I have such a partner myself for which I&#8217;m now publishing 3 apps, I sat down and &#8211; after fighting with Xcode over a second target &#8211; added a couple of lines to the MyAppSales trunk to enable the &#8220;Partner Version&#8221;.</p>
<p>In the PCH file you enable and configure this special version by removing the // in front of the first define. Then you need to specifying your ITC credentials and an NSSet of Apple App Identifiers.</p>

<div class="wp_codebox"><table><tr id="p295611"><td class="code" id="p2956code11"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// to enable the partner version, re-enable the following define and fill in the three values below</span>
<span style="color: #11740a; font-style: italic;">//#define PARTNERVERSION</span>
&nbsp;
<span style="color: #6e371a;">#define PARTNERVERSION_ITC_LOGIN @&quot;account@server.com&quot;</span>
<span style="color: #6e371a;">#define PARTNERVERSION_ITC_PASSWORD @&quot;SECRETPASSWORD&quot;</span>
<span style="color: #6e371a;">#define PARTNERVERSION_FILTER_APPS_SET [NSSet setWithObjects:@&quot;335519920&quot;, @&quot;329678407&quot;, @&quot;374457741&quot;, nil]</span></pre></td></tr></table></div>

<p>I&#8217;ve added a filter for the specified PARTNERVERSION_FILTER_APPS_SET in two places to ignore all lines on sales report where neither the Apple Identifier nor the Parent ID is in this list. Since the app never sees any apps outside of this filter those also won&#8217;t pop up on the apps page.</p>
<p>For the preconfigured account, the app adds this ITC account if there are no accounts defined. So if your partner were to remove this account accidentally it would be configured once more on next app start.</p>
<p>All you need to do after configuring and building a release version is to zip and ship the app and provisioning profile to your partner. Easy enough?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/08/myappsales-for-partners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DTBannerManager</title>
		<link>http://www.drobnik.com/touch/2010/08/dtbannermanager/</link>
		<comments>http://www.drobnik.com/touch/2010/08/dtbannermanager/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 12:42:37 +0000</pubDate>
		<dc:creator>drops</dc:creator>
				<category><![CDATA[Parts]]></category>

		<guid isPermaLink="false">http://www.drobnik.com/touch/?p=2949</guid>
		<description><![CDATA[You have AdMob ads in your apps? Wondering if you could [...]]]></description>
			<content:encoded><![CDATA[<p>You have AdMob ads in your apps? Wondering if you could make a bit more money if you also had iAds were available?</p>
<p>DTBannerManager solves this problem for you. It allows for easily adding both networks to your code. Under iOS 4 it will first try to get an iAd because those also pay for just being displayed. If none is available then it automatically switches to AdMob, so your banner space is never wasted. It also features elegant sliding in and out of the banners and is able to display ad banners even over a tab bar controller, so they are always visible for maximum effect.</p>
<p><img src="http://www.drobnik.com/touch/wp-content/uploads/2010/01/Screen-shot-2010-08-06-at-2.23.55-PM.png" alt="" title="DTBannerManager" width="320" height="120" class="alignnone size-full wp-image-2946" /></p>
<p>You might argue that there are free ad networks out there who promise to do exactly this for free. So why would you want to get this component from me. Well, from you you get full source code and you see exactly what is happening. Also there is no server-side ad mediation happening that might get you in trouble with Apple. I believe that as developer you don&#8217;t want to involve too many additional parties and introduce too many external dependencies. With DTBannerManager you continue own all parts of your code and have full transparency.</p>
<p>What&#8217;s also great is that you can use this component will work on both 3.x and 4.x iOS Versions. This way you can target the broadest possible audience with reaping the benefits of iAds if available.</p>
<p>Adding advertising is exceedingly simple:</p>

<div class="wp_codebox"><table><tr id="p294912"><td class="code" id="p2949code12"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#ifdef FREEVERSION	</span>
	<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>DTBannerManager sharedManager<span style="color: #002200;">&#93;</span> addAdsToViewController<span style="color: #002200;">:</span>tabBarController<span style="color: #002200;">&#93;</span>;
<span style="color: #6e371a;">#endif</span></pre></td></tr></table></div>

<p>Then you can just subscribe to the notifications to adjust the viewing area of your view controllers.</p>
<p>DTBannerManager is proving it&#8217;s worth already in <a href="http://www.drobnik.com/touch/2010/07/geocorder-1-1-0/">GeoCorder [FREE]</a>. There was a bug preventing &#8220;clicking through&#8221; in Ads that I have since fixed. The component is available through the <a href="http://www.drobnik.com/touch/parts-store/">Dr. Touch&#8217;s Parts Store</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.drobnik.com/touch/2010/08/dtbannermanager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
