<?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>Bagonca &#187; iPhone</title>
	<atom:link href="http://www.bagonca.com/blog/category/developer/iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bagonca.com/blog</link>
	<description>Yet another developer blog</description>
	<lastBuildDate>Fri, 18 Jun 2010 09:28:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use tap events instead of click events in iPhone browser</title>
		<link>http://www.bagonca.com/blog/2010/06/18/use-tap-events-instead-of-click-events-in-iphone-browser/</link>
		<comments>http://www.bagonca.com/blog/2010/06/18/use-tap-events-instead-of-click-events-in-iphone-browser/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 09:17:28 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[projectplace]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=851</guid>
		<description><![CDATA[When working on a web app for embedding in a iPhone application we came across jQTouch, a really nifty little jQuery plugin which makes it easy to create a web application UI that really resembles that of a native iPhone application.
We soon encountered a problem due to the fact that click events are rather slow [...]]]></description>
			<content:encoded><![CDATA[<p>When working on a web app for embedding in a iPhone application we came across <a title="jQTouch" href="http://jqtouch.com/">jQTouch</a>, a really nifty little jQuery plugin which makes it easy to create a web application UI that really resembles that of a native iPhone application.</p>
<p>We soon encountered a problem due to the fact that click events are rather slow to fire on the iPhone. There is a delay due to the fact that the iPhone waits for the user to complete a gesture before deciding that the intended gesture was in fact a click.</p>
<p>JQTouch uses divs to navigate between screens, so for example if you have the div</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;primary-view&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span></pre></div></div>

<p>you can simply navigate to it through a normal anchor link, and the transition will thanks to jQTouch be really &#8220;iPhone like&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;#primary-view&quot;</span><span style="color: #339933;">&gt;</span>Primary view<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Our main problem is that we load our content dynamically through Ajax. So our links looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>a onclick<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;fetchContent();&quot;</span> href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;#primary-view&quot;</span><span style="color: #339933;">&gt;</span>Primary view<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span></pre></div></div>

<p>This resulted in a race condition. The anchor link listens to the tap event which is fired much earlier than the click event, and therefore we mostly ended up in empty views. So we needed to replace all onclicks to ontap listeners. The problem then is that we could no longer test our webapp in a normal desktop based Safari browser.</p>
<p>So, we decided to happily go along and write inline onclick events on our links and other interaction elements. But while in the iPhone we see to it that the onClicks are removed and replaced with tap listeners.</p>
<p>That function looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> rebindClicks<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> userAgent <span style="color: #339933;">=</span> navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> isIphone <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>userAgent.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'iphone'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isIphone<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// For each event with an inline onclick</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[onclick]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> onclick <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onclick'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeAttr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onclick'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Remove the onclick attribute</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> preventClickEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// See to it that clicks never happen</span>
            $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tap'</span><span style="color: #339933;">,</span> onclick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Point taps to the onclick</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> preventClickEvent<span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>We now call this little function everytime the DOM is changed. If something turns up with an inline onclick. It is will be rerouted by jQuery to a tap listener instead.</p>
<p>Again, we felt we needed to do this because many of our developers do not have a Mac (and hence do not have the iPhone simulator). And testing on the iPhone can be really time consuming. So for testing during development we wanted to use onClick, and when testing on iPhone we wanted to use taps instead.</p>
<p>But the biggest bonus was without a doubt that things are overall <em>much faster</em> in the web application. Taps fire much faster than clicks in the iPhone.</p>
<p>Here&#8217;s how it looks running the same app both in desktop safari and embedded into the iPhone simulator.</p>
<p><object id="scPlayer" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="862" height="746" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" /><param name="flashVars" value="thumb=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/FirstFrame.jpg&amp;containerwidth=862&amp;containerheight=746&amp;content=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/00000050.swf" /><param name="allowFullScreen" value="true" /><param name="scale" value="showall" /><param name="allowScriptAccess" value="always" /><param name="base" value="http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/" /><param name="src" value="http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/jingswfplayer.swf" /><param name="flashvars" value="thumb=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/FirstFrame.jpg&amp;containerwidth=862&amp;containerheight=746&amp;content=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/00000050.swf" /><param name="allowfullscreen" value="true" /><embed id="scPlayer" type="application/x-shockwave-flash" width="862" height="746" src="http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/jingswfplayer.swf" base="http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/" allowscriptaccess="always" scale="showall" allowfullscreen="true" flashvars="thumb=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/FirstFrame.jpg&amp;containerwidth=862&amp;containerheight=746&amp;content=http://content.screencast.com/users/omgwtflolomg/folders/Jing/media/4df1e2fe-264d-4de7-b72c-4e83d2338601/00000050.swf" bgcolor="#FFFFFF" quality="high"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2010/06/18/use-tap-events-instead-of-click-events-in-iphone-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Submitting iPhone app to App Store</title>
		<link>http://www.bagonca.com/blog/2009/05/08/submitting-iphone-app-to-app-store/</link>
		<comments>http://www.bagonca.com/blog/2009/05/08/submitting-iphone-app-to-app-store/#comments</comments>
		<pubDate>Thu, 07 May 2009 23:38:55 +0000</pubDate>
		<dc:creator>Samuel</dc:creator>
				<category><![CDATA[Innovation]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[inspiration]]></category>
		<category><![CDATA[project management]]></category>
		<category><![CDATA[projectplace]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=374</guid>
		<description><![CDATA[Finally, after two bounces and three weeks of waiting, our first app on App Store is available!
I&#8217;ll keep this post really short!
Pros
Great testing by the App Store review team.
Good and thorough feedback.
Cons
Time consuming! But, reasonable considering the amount of apps that is submitted to the App Store.
iTunes Connect
Some good to knows!
It takes approximately 5 working [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, after two bounces and three weeks of waiting, our first app on App Store is available!</p>
<p>I&#8217;ll keep this post really short!</p>
<blockquote><p>Pros</blockquote >
<li>Great testing by the App Store review team.</li>
<li>Good and thorough feedback.</li>
<blockquote><p>Cons</blockquote >
<li>Time consuming! But, reasonable considering the amount of apps that is submitted to the App Store.</li>
<li>iTunes Connect</li>
<blockquote><p>Some good to knows!</blockquote >
<li>It takes approximately 5 working days before you hear anything from the review team.</li>
<li>If you reject (developer reject) your application and post a new version when an app is undergoing a review, then you will have to wait another 5 more days.</li>
<blockquote><p>Conclusion</blockquote >
The App Store review process: 4 stars out of 5</p>
<blockquote><p>Projectplace for iPhone</blockquote >
If you are curious about our iPhone application, please <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=312388930&amp;mt=8">visit our app section @ App Store</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/05/08/submitting-iphone-app-to-app-store/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Use Flex and set it free</title>
		<link>http://www.bagonca.com/blog/2009/04/17/use-flex-and-set-it-free/</link>
		<comments>http://www.bagonca.com/blog/2009/04/17/use-flex-and-set-it-free/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 12:11:24 +0000</pubDate>
		<dc:creator>PEZ</dc:creator>
				<category><![CDATA[Flex/AS]]></category>
		<category><![CDATA[Innovation]]></category>
		<category><![CDATA[Values]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[inspiration]]></category>
		<category><![CDATA[love]]></category>
		<category><![CDATA[planning]]></category>
		<category><![CDATA[yap]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=135</guid>
		<description><![CDATA[I love my work managing Projectplace Labs. (Was: A development version of Yap).]]></description>
			<content:encoded><![CDATA[<p>I work at <a title="Project Collaboration Playground" href="http://www.projectplacelabs.com">Projectplace Labs</a>. In fact I&#8217;m managing it. No doubt it&#8217;s the best job I&#8217;ve ever had. Imagine getting payed for experimenting with far out things all day. Two examples:</p>
<div id="attachment_140" class="wp-caption alignright" style="width: 160px"><a href="http://www.projectplacelabs.com"><img class="size-full wp-image-140" title="Projectplace for iPhone" src="http://www.bagonca.com/blog/wp-content/uploads/2009/04/iphoneapppp.jpg" alt="Samuel is da man!" width="150" height="261" /></a><p class="wp-caption-text">Samuel is da man!</p></div>
<ul>
<li><a href="http://www.bagonca.com/blog/author/samuel/">Samuel</a>, who also  works at the lab <em>and</em> blogs on this site, started to play with the iPhone SDK some month ago and just yesterday he sent a Projectplace client for the iPhone to AppStore. It should appear there any day soon. Computer Sweden <a href="http://computersweden.idg.se/2.2683/1.224077/iphone-tar-plats-i-foretaget">wrote about it today</a> (Swedish).</li>
<li>A year ago I tried out <a href="http://www.flashsandy.org/">Sandy3D </a>(awesome 3D engine for Flash written in AS3) and quickly got a prototype up for a Cooliris-inspired photo wall, it was WOW to me so I called it <a href="http://files.projectplace.com/bttr/WoWalbum.html">WowAlbum</a>. Not as immediately business applicable as Samuel&#8217;s iPhone app, but a fun thing to do.</li>
</ul>
<p>Projectplace Labs is very much inspired by those big, innovative, forces out there. Mozilla Labs, Microsoft Office Labs, Adobe Labs and, of course, Google Labs. Google is probably our main inspirational source. We&#8217;re trying to <a title="Whatever works for Google" href="http://harvardbusinessonline.hbsp.harvard.edu/b01/en/common/item_detail.jhtml?id=R0804C">reverse engineer Google&#8217;s innovation machine</a> and apply what we feel fits us (or at least try to convince our managers to let us apply it). We&#8217;ve also taken Quincy Jones&#8217; receipt for success to our hearts;</p>
<blockquote><p><a href="http://edgehopper.com/learning-from-quincy-jones/">Hire the best and set them free.</a></p></blockquote>
<p>We apply it on all levels. <em>Ideas, creativity, people, innovation, inspiration, code, joy, love.</em> <strong>Unleash!</strong></p>
<div id="attachment_148" class="wp-caption alignright" style="width: 210px"><img class="size-full wp-image-148" title="Yap flash based planning tool" src="http://www.bagonca.com/blog/wp-content/uploads/2009/04/yapblack-small.png" alt="Yap - planning made fun" width="200" height="106" /><p class="wp-caption-text">Yap - planning made fun</p></div>
<p>Ummm, I was definately not planning to write about Projectplace Labs in this blog. Got a bit carried away there. I was mainly about to use the Bagonca server to make a development version of <a title="Fast and easy task scheduling" href="http://www.projectplacelabs.com/Yap.aspx">Yap</a> available to a guy I&#8217;m working with at <a href="http://www.a-dato.net">A-Dato</a>. Then I thought, heck I can blog about it, and then I felt I needed to tell about where I work.</p>
<p>And now I need to tell you something about Yap too, right? You can read a little about it at Projectplace Labs and also at <a href="http://projectplaceideas.feedback20.com/category/103430-yap-fast-and-easy-planning">Projectplace Ideas</a>. To cut a long story short:</p>
<blockquote><p>We, Projectplace, want to be the company who made project planning fun.</p></blockquote>
<p>That development version of Yap that you can access even before it appears on Projectplace Labs? Don&#8217;t worry, I haven&#8217;t fogotten, here goes:</p>
<ul>
<li><a href="http://www.bagonca.com/yap" target="_blank">Faster than Excel, easier than MS Project</a></li>
</ul>
<p>Now, how cool does this make Bagonca? It even publishes Projectplace Labs stuff before Labs! =)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/04/17/use-flex-and-set-it-free/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>iPhone tip #2 &#8211; What is my current location?</title>
		<link>http://www.bagonca.com/blog/2009/04/09/iphone-tip-2-what-is-my-current-location/</link>
		<comments>http://www.bagonca.com/blog/2009/04/09/iphone-tip-2-what-is-my-current-location/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 22:23:44 +0000</pubDate>
		<dc:creator>Samuel</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[CoreLocation]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Location]]></category>
		<category><![CDATA[Map]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=106</guid>
		<description><![CDATA[The iPhone has GPS built-in, which makes the phone really powerful and enables developers to innovate cool and cutting edge applications!
The iPhone devcenter has some sample code explaining how the CoreLocation framework works. But, I found that example a bit hard to understand&#8230;
Here is an easier way of finding your current location from your iPhone.
Let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>The iPhone has GPS built-in, which makes the phone really powerful and enables developers to innovate cool and cutting edge applications!</p>
<p>The iPhone devcenter has some sample code explaining how the CoreLocation framework works. But, I found that example a bit hard to understand&#8230;</p>
<p>Here is an easier way of finding your current location from your iPhone.</p>
<p>Let&#8217;s start with the interface/header file.<br />
CurrentLocationController.h</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;CoreLocation/CoreLocation.h&gt;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> CurrentLocationController <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span> &lt;CLLocationManagerDelegate&gt; <span style="color: #002200;">&#123;</span>
	CLLocationManager <span style="color: #002200;">*</span>locationManager;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> CLLocationManager <span style="color: #002200;">*</span>locationManager;
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>locationManager<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocationManager <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>manager didUpdateToLocation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocation <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>newLocation fromLocation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocation <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>oldLocation;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>locationManager<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocationManager <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>manager didFailWithError<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>error;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>Note: Our object &#8220;implements&#8221; the CLLocationManagerDelegate protocol. We &#8220;implement&#8221; two methods,  locationManager:didUpdateToLocation:fromLocation: and locationManager:didFailWithErrorfrom :, from CLLocationManagerDelegate. The first method is invoked when a new location is available and the second one if an error has occurred.</p>
<p>Here comes the implementation:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;CurrentLocationController.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@implementation</span> CurrentLocationController
&nbsp;
<span style="color: #a61390;">@synthesize</span> locationManager;
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span> init <span style="color: #002200;">&#123;</span>
    self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super init<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>self <span style="color: #002200;">!=</span> <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        self.locationManager <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>CLLocationManager alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
        self.locationManager.delegate <span style="color: #002200;">=</span> self;
    <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>locationManager<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocationManager <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>manager didUpdateToLocation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocation <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>newLocation fromLocation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocation <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>oldLocation <span style="color: #002200;">&#123;</span>
    NSLog<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>newLocation description<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</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>locationManager<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocationManager <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>manager didFailWithError<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>error <span style="color: #002200;">&#123;</span>
    NSLog<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>error description<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</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>self.locationManager release<span style="color: #002200;">&#93;</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: #a61390;">@end</span></pre></div></div>

<p>The only important thing to note is the line</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">self.locationManager.delegate <span style="color: #002200;">=</span> self;</pre></div></div>

<p>. Here we set our own object as the delegate, which means that all the location messages will be forwarded to CurrentLocationController.</p>
<p>I hope this will give you more time innovating, instead of developing <a href="http://www.mayoclinic.com/health/trichotillomania/DS00895">Trichotillomania</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/04/09/iphone-tip-2-what-is-my-current-location/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>iPhone tip #1 &#8211; URL encoding in Objective-C</title>
		<link>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/</link>
		<comments>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 21:01:41 +0000</pubDate>
		<dc:creator>Samuel</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[NSUrl]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.bagonca.com/blog/?p=100</guid>
		<description><![CDATA[If you are n00b when it comes to iPhone development, then you&#8217;ve come to the right place! We&#8217;ll be posting howtos, tips and tricks continuously.
So, how do you URL enconde a string? It&#8217;s quite simple if you know how.  

+ &#40;NSString *&#41;urlEncodeValue:&#40;NSString *&#41;str
&#123;
NSString *result = &#40;NSString *&#41; CFURLCreateStringByAddingPercentEscapes&#40;kCFAllocatorDefault, &#40;CFStringRef&#41;str, NULL, CFSTR&#40;”:/?#[]@!$&#38;’()*+,;=”), kCFStringEncodingUTF8);
return &#91;result autorelease&#93;;
&#125;

To create an [...]]]></description>
			<content:encoded><![CDATA[<p>If you are n00b when it comes to iPhone development, then you&#8217;ve come to the right place! We&#8217;ll be posting howtos, tips and tricks continuously.</p>
<p>So, how do you URL enconde a string? It&#8217;s quite simple if you know how. <img src='http://www.bagonca.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>urlEncodeValue<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>str
<span style="color: #002200;">&#123;</span>
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>result <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> CFURLCreateStringByAddingPercentEscapes<span style="color: #002200;">&#40;</span>kCFAllocatorDefault, <span style="color: #002200;">&#40;</span>CFStringRef<span style="color: #002200;">&#41;</span>str, <span style="color: #a61390;">NULL</span>, CFSTR<span style="color: #002200;">&#40;</span>”<span style="color: #002200;">:/</span>?<span style="color: #6e371a;">#[]@!$&amp;’()*+,;=”), kCFStringEncodingUTF8);</span>
<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>result autorelease<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>To create an URL object, do like this:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span>encodedUrlString<span style="color: #002200;">&#93;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bagonca.com/blog/2009/04/08/iphone-tip-1-url-encoding-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
