<?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; tutorial</title>
	<atom:link href="http://www.bagonca.com/blog/tag/tutorial/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>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>
