<?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>iCodeBlog</title>
	<atom:link href="http://icodeblog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://icodeblog.com</link>
	<description>iPhone Programming Tutorials</description>
	<lastBuildDate>Thu, 04 Feb 2010 22:17:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhone Coding Recipe &#8211; Shortening URLs</title>
		<link>http://icodeblog.com/2010/02/04/iphone-coding-recipe-shortening-urls/</link>
		<comments>http://icodeblog.com/2010/02/04/iphone-coding-recipe-shortening-urls/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 21:42:35 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Recipes]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[iPhone Coding]]></category>
		<category><![CDATA[tr.im api]]></category>
		<category><![CDATA[url shortening iphone]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1756</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2010/02/04/iphone-coding-recipe-shortening-urls/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2010/02/trim.png" class="alignleft tfe wp-post-image" alt="" title="trim" /></a>I had some a to shorten URLs for an in-application Twitter client I'm working on and thought I would share my simple solution with you guys.

It's actually pretty straight forward and can be done in 1 line of code.  I have broken it up into several for clarity.]]></description>
			<content:encoded><![CDATA[<p>I had some a to shorten URLs for an in-application Twitter client I&#8217;m working on and thought I would share my simple solution with you guys.</p>
<p>It&#8217;s actually pretty straight forward and can be done in 1 line of code.  I have broken it up into several for clarity.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>url    <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://brandontreb.com&quot;</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>apiEndpoint <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://api.tr.im/v1/trim_simple?url=%@&quot;</span>,url<span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>shortURL <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithContentsOfURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span>apiEndpoint<span style="color: #002200;">&#93;</span> 
		 encoding<span style="color: #002200;">:</span>NSASCIIStringEncoding 
		 error<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Long: %@ - Short: %@&quot;</span>,url,shortURL<span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Outputs Long: http://brandontreb.com - Short: http://tr.im/MRDd</span></pre></div></div>

<p>Pretty easy huh?</p>
<p>The magic here is in a method that Apple gave us as part of NSString.  This method is called stringWithContentsOfURL.  It will easily allow you to grab the text of any remote source.</p>
<p>I have used Tr.im as an example here because their service is very easy to use and has little overhead.  I would have used bit.ly but they return a JSON string which would then have to be parsed.  Tr.im&#8217;s trim_simple service simply outputs the string of the shortened URL.</p>
<p>Sure Twitter may shorten links for you automatically, but what if you want to use a custom service? Or,&#8230;wait for it&#8230; use it for something other than Twitter (please post in the comments if you do. I would love to hear some other uses <img src='http://icodeblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>Questions? Comments? Complaints?</p>
<p>Happy iCoding</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2010/02/04/iphone-coding-recipe-shortening-urls/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Who&#8217;s Up For Some iPad Coding?</title>
		<link>http://icodeblog.com/2010/01/27/whos-up-for-some-ipad-coding/</link>
		<comments>http://icodeblog.com/2010/01/27/whos-up-for-some-ipad-coding/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 19:48:37 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ipad development]]></category>
		<category><![CDATA[ipad programming]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1732</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2010/01/27/whos-up-for-some-ipad-coding/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_014-150x150.png" class="alignleft wp-post-image tfe" alt="" title="screenshot_01" /></a>
Apple&#8217;s developer center is down for now.  But, I can assure you we will be downloading the SDK as soon as it goes live.
Get ready for some iPad dev tutorials!
]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_014.png"><img class="alignnone size-medium wp-image-1733" title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_014-300x279.png" alt="" width="300" height="279" /></a></p>
<p>Apple&#8217;s developer center is down for now.  But, I can assure you we will be downloading the SDK as soon as it goes live.</p>
<p>Get ready for some iPad dev tutorials!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2010/01/27/whos-up-for-some-ipad-coding/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>App Store Overpopulation</title>
		<link>http://icodeblog.com/2010/01/15/app-store-overpopulation/</link>
		<comments>http://icodeblog.com/2010/01/15/app-store-overpopulation/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 14:00:23 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1724</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2010/01/15/app-store-overpopulation/"><img align="left" hspace="5" width="150" src="http://www.iphonestalk.com/images/app_store.jpg" class="alignleft wp-post-image tfe" alt="" title="App Store" /></a>The number of applications in the app store is approaching 100,000. The quality of applications in this massive of a marketplace is hard to measure. Apple provides the star ratings for applications but I like to have a few more sources. Check out:
app.itize.us
app.itize.us is a site highlighting the best of emerging apps in the store. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone" title="App Store" src="http://www.iphonestalk.com/images/app_store.jpg" alt="" width="192" height="167" />The number of applications in the app store is approaching 100,000. The quality of applications in this massive of a marketplace is hard to measure. Apple provides the star ratings for applications but I like to have a few more sources. Check out:</p>
<h2><span style="color: #ff6600;"><a href="http://app.itize.us/wp/">app.itize.us</a></span></h2>
<p>app.itize.us is a site highlighting the best of emerging apps in the store. The site is really well categorized and will surely show you some hidden great apps.</p>
<h2><span style="color: #000000;"><a href="http://www.freshapps.com/" target="_blank">Fresh Apps</a></span></h2>
<p><span style="color: #000000;">Fresh Apps is a user driven review site to supplement the star and comment sections of the App Store which was created by iCodeBlog contributor Brandon Trebitowski (brandontreb). User can get an account and set apps as &#8220;Fresh&#8221; to boost their popularity on the site.</span></p>
<h2><a href="#mce_temp_url#">Touch Arcade</a></h2>
<p>Touch Arcade is a very popular iPhone game review and preview site. The site was created by the founder of Mac Rumors and is a one stop show for a look at the most quality games on or coming to the store.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2010/01/15/app-store-overpopulation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CES 2010 &#8211; Mobile Processors, eReaders and Tablets</title>
		<link>http://icodeblog.com/2010/01/12/ces-2010-mobile-processors-ereaders-and-tablets/</link>
		<comments>http://icodeblog.com/2010/01/12/ces-2010-mobile-processors-ereaders-and-tablets/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 06:00:48 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CES]]></category>
		<category><![CDATA[Consumer Electronics Show]]></category>
		<category><![CDATA[eInk]]></category>
		<category><![CDATA[eReader]]></category>
		<category><![CDATA[Intel]]></category>
		<category><![CDATA[Kindle]]></category>
		<category><![CDATA[Nook]]></category>
		<category><![CDATA[Tablet]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1710</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2010/01/12/ces-2010-mobile-processors-ereaders-and-tablets/"><img align="left" hspace="5" width="150" src="http://www.gadget-paradise.com/news_images/000065_ces.jpg" class="alignleft wp-post-image tfe" alt="" title="" /></a>This year I was lucky enough to go to CES in beautiful Las Vegas. While I’m sure you all know, CES is the Consumer Electronics Show, and it is one of the largest trade shows in the world. Everyone who is anyone is at this show (except Apple), and it has historically been a place [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" src="http://www.gadget-paradise.com/news_images/000065_ces.jpg" alt="" width="280" height="170" />This year I was lucky enough to go to <a href="http://www.cesweb.org/" target="_blank">CES in beautiful Las Vegas</a>. While I’m sure you all know, CES is the Consumer Electronics Show, and it is one of the largest trade shows in the world. Everyone who is anyone is at this show (<a href="http://ces.cnet.com/8301-31045_1-10431012-269.html" target="_blank">except Apple</a>), and it has historically been a place for companies to reveal big new products. <a href="http://www.microsoft.com/surface/" target="_blank">Microsoft in 2008 released the Surface</a> and last year Palm released the <a href="http://www.palm.com/us/products/phones/pre/" target="_blank">Palm Pre</a>. This year was kind of a dud in terms of large announcements but I wanted to throw up a post with some highlights.</p>
<h2><span style="color: #ff6600;"> Intel’s Core Chips go Mobile </span></h2>
<p>In my opinion Intel is the big winner this year. They took there very popular i processor series and released the mobile version in <a href="http://www.tomshardware.com/reviews/mobile-core-i5-arrandale,2522.html" target="_blank">i3, i5 and i7</a> flavors. Chatter is already abounding that these are going to find their way into the next revision of the MacBook Pro line; and I for one am really excited to get these beasts in a laptop. The new 27’’ iMac can be equipped with them and I can personally verify they <a href="http://www.imdb.com/title/tt0117571/" target="_blank">SCREAM</a>.</p>
<h2><span style="color: #ff6600;"> eReaders </span></h2>
<p>The most incredible thing to me at CES was the number of eReaders I saw. I personally walked by 10+ companies with either real eBook products, or demos of the eReader concepts. For those of you who don’t know, eBook readers, such as the <a href="http://www.amazon.com/Kindle-Amazons-Original-Wireless-generation/dp/B000FI73MA" target="_blank">Kindle</a> of <a href="http://www.barnesandnoble.com/nook/" target="_blank">Nook</a>, utilize a display technology called <a href="http://www.eink.com/" target="_blank">eInk</a> in order to show text that is readable in full sunlight, has an extremely small electricity requirement, requires a small amount of data to fill a screen. The Kindle has been around for several years and has received mild success, but this apparently is the year for everyone else to jump in the ring.</p>
<p>I tried lots of these devices, and have also tried the Kindle at length. I personally don’t see a future for eInk. It seems like a fun technology with some definite advantages that people are hopping on but there are two flaws which will inevitably banish this tech from the market.</p>
<p>Refresh rate and Color.</p>
<p>These things are SLOW. Like way slow compared to any modern digital device. The refresh of the screen is choppy and has a minimum of a 1 second delay. Imagine the Sketch character from <a href="http://www.mytoybox.com/MAP6059.html" target="_blank">Toy Story 1 and 2 doing the “Draw” game with Woody</a>. That is the kind of speed you get. Impressive if it was an etch-a-sketch annoying if it is supposed to be your digital display. This of course effects functionality as well. These devices seem a very long way off from playing any kind of respectable video and appear to have no possibility of color on the horizon. I am somewhat baffled by the popularity of these devices but there are going to be a lot of them gathering dust over the next few years as much better low light, energy efficient LCD and LED displays are released.</p>
<h2><span style="color: #ff6600;"> Tablet, Tablets Everywhere, but no Software to be Seen</span></h2>
<p>Almost every major consumer electronics company (except for Apple) showed or hinted at some tablet device they are getting together for 2010. Lenovo came up with <a href="http://shop.lenovo.com/us/landing_pages/info/10/skylight" target="_blank">Skylight, a hybrid laptop</a>, tablet combination. Dell showed off their <a href="http://gizmodo.com/5443837/first-hands+on-and-video-dell-mini-5-android-slate" target="_blank">Mini 5</a> to a lucky few, and Balmer showed off a bunch of “Slate” form factor PC’s to be released later this year. I saw <a href="http://www.microsoft.com/windows/windows-7/" target="_blank">Windows 7</a> running on these, I saw Android running on most. But my major problem is that no one seems to have put much time into the software for a device like this yet.</p>
<p><a href="http://www.android.com/" target="_blank">Android</a> is totally open source. You could literally have your company completely skin it, much like HTC with Window Mobile, and create the kind of environment you envision. I only saw one actual tablet in person that had any kind of interface tweaking to facilitate the new form factor, but this is an area were some amateur dev can make their first million this year. If we assume for a moment that Apple releases some cool tablet style device that gains the public’s interest, the market will grow and grow. From what I saw at CES lots of people have hardware that utilizes standard Android, but what they are all missing is a special distro that rethinks the Android UI for a larger device.</p>
<p>This should be a red alert to all up and coming developers who want to make a name for themselves. Sit down and start developing android for a full resolution touch experience. I would bet that developers with this kind of stuff in their portfolios are going to be hot commodities this year. And who knows maybe you could make THE UI. Devs, start your engines.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2010/01/12/ces-2010-mobile-processors-ereaders-and-tablets/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>iPhone Coding Recipe: Live Character Counter, Word filter, and 1337 Translator For A UITextField</title>
		<link>http://icodeblog.com/2010/01/06/live-character-counter-for-a-uitextfield/</link>
		<comments>http://icodeblog.com/2010/01/06/live-character-counter-for-a-uitextfield/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 18:46:57 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Recipes]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[1337]]></category>
		<category><![CDATA[Editing Changed]]></category>
		<category><![CDATA[iphone programming]]></category>
		<category><![CDATA[UITextField]]></category>
		<category><![CDATA[Word filter]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1686</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2010/01/06/live-character-counter-for-a-uitextfield/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2010/01/1337_Cereal_by_Alaskara-150x150.jpg" class="alignleft tfe wp-post-image" alt="" title="1337_Cereal_by_Alaskara" /></a><p>I'm sure you have seen a Twitter client such as <a href="http://stone.com/Twittelator/index.html">Twittelator Pro</a> or <a href="http://www.atebits.com/tweetie-iphone/">Tweetie 2</a> count down the characters as you type your Tweet.  This is done by responding to the Editing Changed action on a UITextField.</p>  

<p>Today, I will show you how you can implement this functionality in your application as well as show you some other real world examples of responding to this action.  Here are a few of the uses that we will discuss:</p>
<ul>
	<li>Countdown of characters allowed - Used when the user is limited by a certain number of characters</li>
	<li>Word filter - useful in filtering out swear words or other unwanted text</li>
	<li>Live translator - our example will translate english to <a href="http://en.wikipedia.org/wiki/Leet">1337</a> :)</li>
</ul>
<p>I will create the core code and show you how to modify it slightly to implement the other 2 applications.</p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure you have seen a Twitter client such as <a href="http://stone.com/Twittelator/index.html">Twittelator Pro</a> or <a href="http://www.atebits.com/tweetie-iphone/">Tweetie 2</a> count down the characters as you type your Tweet.  This is done by responding to the Editing Changed action on a UITextField.  Today, I will show you how you can implement this functionality in your application as well as show you some other real world examples of responding to this action.  Here are a few of the uses that we will discuss:</p>
<ul>
<li>Countdown of characters allowed &#8211; Used when the user is limited by a certain number of characters</li>
<li>Word filter &#8211; useful in filtering out swear words or other unwanted text</li>
<li>Live translator &#8211; our example will translate english to <a href="http://en.wikipedia.org/wiki/Leet">1337</a> <img src='http://icodeblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p>I will create the core code and show you how to modify it slightly to implement the other 2 applications.</p>
<p>Let&#8217;s begin by creating the countdown application.</p>
<h2>1. Start With A View Based Application</h2>
<p>Name the application TextMonitor.  I&#8217;m giving it this generic name since it will become one of 3 applications.</p>
<div id="attachment_1688" class="wp-caption alignnone" style="width: 610px"><a href="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_012.png"><img class="size-full wp-image-1688" title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_012.png" alt="" width="600" height="442" /></a><p class="wp-caption-text">View based application </p></div>
<h2>2. Add You IBOutlets And IBActions</h2>
<p>Before creating my User Interfaces, I always like to declare the  IBOutles and IBActions first.  That way, I only need to open Interface Builder one time to add the UI components and connect them up.  Open TextMonitorViewController.h and add the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import </span>
&nbsp;
<span style="color: #a61390;">@interface</span> TextMonitorViewController <span style="color: #002200;">:</span> UIViewController <span style="color: #002200;">&#123;</span>
	IBOutlet UITextView <span style="color: #002200;">*</span> liveOutputTextView;
<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> IBOutlet UITextView <span style="color: #002200;">*</span> liveOutputTextView;
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>textFieldDidUpdate<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>Pretty straight forward.  We first declare an IBOutlet for the UITextView that we will be updating.  It will be used to show our characters remaining.  Next, we declare an IBAction that will be called every time the user types a character in the UITextField.  Now that our properties and actions have been set up, it&#8217;s time to create our interface.</p>
<h2>3. Creating The Interface</h2>
<p>Open up the file TextMonitorViewController.xib in Interface Builder.  Drag a UITextField and a UITextView on to the main view.  It should look something like this (I change the colors a bit).</p>
<div id="attachment_1689" class="wp-caption alignnone" style="width: 330px"><a href="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_013.png"><img class="size-full wp-image-1689" title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_013.png" alt="" width="320" height="502" /></a><p class="wp-caption-text">Main View</p></div>
<p>Once you have created the view, connect the UITextView to the liveOutputTextView IBOutlet of the File&#8217;s Owner object. To do this click on &#8220;File&#8217;s Owner&#8221; in the window titled &#8220;TextMonitorViewController.xib&#8221;, the click Tools -&gt; Connections Inspector.  Drag from the circle that sais liveOutputTextView to your UITextView on the screen and release.</p>
<p>Next, you will need to connect the textFieldDidUpdate IBOutlet to the Editing Changed action of the UITextField.  Click on the UITextField and open the Connection Inspector.  Click and drag from the Editing Changed action to the File&#8217;s Owner object.  The method ﻿textFieldDidUpdate should appear, mouse over it and release the click.</p>
<p>The connections inspector window of File&#8217;s Owner should now look like this.</p>
<div id="attachment_1691" class="wp-caption alignnone" style="width: 297px"><a href="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_021.png"><img class="size-full wp-image-1691" title="screenshot_02" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_021.png" alt="" width="287" height="195" /></a><p class="wp-caption-text">Connections Inspector</p></div>
<p>You may now close Interface Builder and return to the code.  The next thing we will do is implement the textFieldDidUpdate method.</p>
<h2>4. The textFieldDidUpdate Method</h2>
<p>This is the method where we will put all of our code.  Open up TextMonitorViewController.m and add the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;TextMonitorViewController.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@implementation</span> TextMonitorViewController
&nbsp;
<span style="color: #a61390;">@synthesize</span> liveOutputTextView;
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span> textFieldDidUpdate<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender <span style="color: #002200;">&#123;</span>
	UITextField <span style="color: #002200;">*</span> textField <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>UITextField <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> sender;
	<span style="color: #a61390;">int</span> maxChars <span style="color: #002200;">=</span> <span style="color: #2400d9;">140</span>;
	<span style="color: #a61390;">int</span> charsLeft <span style="color: #002200;">=</span> maxChars <span style="color: #002200;">-</span> <span style="color: #002200;">&#91;</span>textField.text length<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>charsLeft <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		UIAlertView <span style="color: #002200;">*</span> alert <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;No more characters&quot;</span>
			message<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;You have reached the character limit of %d.&quot;</span>,maxChars<span style="color: #002200;">&#93;</span>
			delegate<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span>
			 cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Ok&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>alert show<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>alert release<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	liveOutputTextView.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%d characters remaining.&quot;</span>,charsLeft<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>viewDidUnload <span style="color: #002200;">&#123;</span>
	liveOutputTextView <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</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>super dealloc<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>liveOutputTextView release<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>The first thing that must be done is to synthesize the liveOutputTextView property.  That should be pretty obvious. Let&#8217;s examine the code for the textFieldDidUpdate method.</p>
<p>First, we cast the sender object to a UITextField.  This is because we know that a UITextField is invoking this method and passing in a reference to itself.  Next, we specify the maximum number of characters allowed (I used the Twitter standard of 140).  Following this we simply see how many characters the user has left by subtracting the string length of the user input from the maximum characters allowed.  If you wanted to simply count the characters that the user typed, you would not need this additional math, you could simple output [textField.text length].</p>
<p>I have put in a check to see if the user has typed all 140 characters.  If so, I display a message to them notifying them that they don&#8217;t have any remaining characters.  At this point, I chose not to implement the code to prevent them from typing when they reach the limit (I&#8217;ll leave that as a challenge to you) as most Twitter clients allow you to go over the limit and post to <a href="http://www.twitlonger.com/">twitlonger</a>.</p>
<p>Finally, we update the UITextView to notify the user how many characters they have already typed.  The final product should look something like this.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2010/01/Screen-shot-2010-01-06-at-10.49.23-AM.png"><img class="alignnone size-full wp-image-1693" title="Screen shot 2010-01-06 at 10.49.23 AM" src="http://icodeblog.com/wp-content/uploads/2010/01/Screen-shot-2010-01-06-at-10.49.23-AM.png" alt="" width="414" height="770" /></a></p>
<p>Now that you have seen how to update a UITextView in real time, I will show you how we could alter our textFieldDidUpdate method, to change the program entirely.</p>
<h2>Creating a word filter</h2>
<p>Our word filter will be pretty simple.  We will create an NSDictionary where the keys will be swear words and the values will be their replacements.  We will then enumerate over the keys of the dictionary and replace them in display text with their values.  To do this, replace the code in textFieldDidUpdate with the following code.</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>IBAction<span style="color: #002200;">&#41;</span> textFieldDidUpdate<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender <span style="color: #002200;">&#123;</span>
	UITextField <span style="color: #002200;">*</span> textField <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>UITextField <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> sender;
&nbsp;
	<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span> filteredWords <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span>
			 <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;fecal matter&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;poop&quot;</span>,
			 <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;patooti&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;butt&quot;</span>,
			 <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Worst band ever&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Nickelback&quot;</span>,
			 <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;nice person&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;douche bag&quot;</span>,<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> newString <span style="color: #002200;">=</span> textField.text;
&nbsp;
	<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> naughtyWord <span style="color: #a61390;">in</span> filteredWords.allKeys<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> goodWord <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>filteredWords objectForKey<span style="color: #002200;">:</span>naughtyWord<span style="color: #002200;">&#93;</span>;
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;replacing %@ &quot;</span>,naughtyWord<span style="color: #002200;">&#41;</span>;
		newString <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>newString stringByReplacingOccurrencesOfString<span style="color: #002200;">:</span>naughtyWord
			withString<span style="color: #002200;">:</span>goodWord<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	liveOutputTextView.text <span style="color: #002200;">=</span> newString;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>The result is actually quite amusing.  Check out the screenshot below. iCodeBlog is a family friendly iPhone development site <img src='http://icodeblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://icodeblog.com/wp-content/uploads/2010/01/Screen-shot-2010-01-06-at-11.02.45-AM.png"><img class="alignnone size-full wp-image-1694" title="Screen shot 2010-01-06 at 11.02.45 AM" src="http://icodeblog.com/wp-content/uploads/2010/01/Screen-shot-2010-01-06-at-11.02.45-AM.png" alt="" width="414" height="770" /></a></p>
<h2>Creating a 1337 Translator</h2>
<p>We can now apply this same concept to create a 1337 translator.  The translator will translate the characters as the user types into 1337 speak. (Only the 133737 0f h4&#215;0r5 5p34k 1337).  Replace the code in textFieldDidUpdate with the code below to create your translator.</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>IBAction<span style="color: #002200;">&#41;</span> textFieldDidUpdate<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender <span style="color: #002200;">&#123;</span>
	UITextField <span style="color: #002200;">*</span> textField <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>UITextField <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> sender;
&nbsp;
	<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span> l337 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span>
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;4&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;a&quot;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;|3&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;b&quot;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;3&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;e&quot;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;1&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;i&quot;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;1&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;l&quot;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;0&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;o&quot;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;|2&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;r&quot;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;5&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;s&quot;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;7&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;t&quot;</span>,
						   <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> newString <span style="color: #002200;">=</span> textField.text;
&nbsp;
	<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> word <span style="color: #a61390;">in</span> l337.allKeys<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> h4x <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>l337 objectForKey<span style="color: #002200;">:</span>word<span style="color: #002200;">&#93;</span>;
		newString <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>newString stringByReplacingOccurrencesOfString<span style="color: #002200;">:</span>word withString<span style="color: #002200;">:</span>h4x<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	liveOutputTextView.text <span style="color: #002200;">=</span> newString;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>For those of you who don&#8217;t know what 1337 is, <a href="http://en.wikipedia.org/wiki/Leet">read up on it</a>.  Check out the result that it produces.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2010/01/Screen-shot-2010-01-06-at-11.21.15-AM.png"><img class="alignnone size-full wp-image-1699" title="Screen shot 2010-01-06 at 11.21.15 AM" src="http://icodeblog.com/wp-content/uploads/2010/01/Screen-shot-2010-01-06-at-11.21.15-AM.png" alt="" width="414" height="770" /></a></p>
<p>This translator is actually pretty stupid, but you can see how you could use this to do all sorts of other translations.  A good programming challenge for you could be to make a translator that does base 10 to binary.</p>
<p>So, that concludes our tutorial on live updates based on the user input.  I&#8217;m sure we will be seeing a whole slew of terrible character counters, word filters, and 1337 translators in the app store after this.  Send me the links so that I may partake in the making fun <img src='http://icodeblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://twitter.com/brandontreb">Follow me on Twitter</a></p>
<p>Download the source for this tutorial here <a href="http://icodeblog.com/wp-content/uploads/2010/01/TextMonitor.zip">TextMonitor.zip</a></p>
<p>Until next time, happy iCoding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2010/01/06/live-character-counter-for-a-uitextfield/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Cocoa Development in 2010</title>
		<link>http://icodeblog.com/2010/01/05/cocoa-development-in-2010/</link>
		<comments>http://icodeblog.com/2010/01/05/cocoa-development-in-2010/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 10:00:07 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1583</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2010/01/05/cocoa-development-in-2010/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/12/Downloads1-150x150.png" class="alignleft tfe wp-post-image" alt="" title="Downloads" /></a>2009 will be known as the year  the world learned the word app. With the first full calendar year of the app store coming to a close it is amazing to look back and see the growth that has occurred in this market. There are about 100,000 applications now available in the app store, give [...]]]></description>
			<content:encoded><![CDATA[<p>2009 will be known as the year  the world learned the word app. With the first full calendar year of the app store coming to a close it is amazing to look back and see the growth that has occurred in this market. There are about 100,000 applications now available in the app store, give or take, with more being added every day. While this might seem like a bad thing to the average developer, there seems to be a correlation, at least for the time being, between the number of applications and the number of downloads.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/12/Apps.png"><img class="alignleft size-large wp-image-1589" title="Apps" src="http://icodeblog.com/wp-content/uploads/2009/12/Apps-1024x523.png" alt="" width="614" height="314" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/12/Downloads1.png"><img class="alignleft size-large wp-image-1591" title="Downloads" src="http://icodeblog.com/wp-content/uploads/2009/12/Downloads1-1024x568.png" alt="" width="614" height="341" /></a></p>
<p>Piper Jaffray has been quoted as saying that the app store has the potential to become a profitable billion dollar market, and 2009 is certainly a good indication of future success. People seem to love apps. These bite sized games, utilities, sports, news, jokes are robust enough to enjoy but small enough for our ever decreasing attention spans.  As a developer 2009 was a great year for Cocoa tools, lets take a look back at some of the great things made available from the developer community.</p>
<ul>
<li>Facebook developer Joe Hweitt was kind enough to make his custom <a title="Joe Hweitt Custom iPhone UI Elements" href="http://joehewitt.com/post/the-three20-project/" target="_blank">UI elements open source</a></li>
<li><a title="Joe Hweitt Custom iPhone UI Elements" href="http://joehewitt.com/post/the-three20-project/" target="_blank"></a>Teehan+Lax created and continued to update their <a title="iPhone UI Photoshop Template" href="http://www.teehanlax.com/blog/2009/06/18/iphone-gui-psd-30/" target="_blank">iPhone Photoshop Template</a> which is the quickest way to do a mockup of an app for clients.</li>
<li>TouchCode released <a title="Touch Code" href="http://code.google.com/p/touchcode/" target="_blank">TouchXML and several other packages</a> as open source alternatives to some of the standard XML Parser object that apple supplies.</li>
<li>Nice little tools like <a title="NSDate+Helper" href="http://github.com/billymeltdown/nsdate-helper" target="_blank">NSDate+Helper</a> were released to make using some Cocoa objects simpler.</li>
<li><a title="OpenFeint" href="http://www.openfeint.com/" target="_blank">OpenFeint</a> matured and became an important part of many games.</li>
<li><a title="AdMob" href="http://www.admob.com/" target="_blank">AdMob</a> after less than 3 years of existence was acquired by Google for $750 Million!</li>
</ul>
<p>The iPhone developer community continues to evolve as developers create better and better tools. This makes development of advanced features, such as leader boards and multiplayer easier, but also raises the bar on what users expect from applications. 2010 will surely have higher quality applications and greater competition as developers get better at tailoring software specifically for the iPhone.</p>
<h2><span style="color: #ff6600;">What&#8217;s coming up in 2010</span></h2>
<p>With 2009 in the books, and people starting to see the reality of the app store, I imagine we will see a general decline in the app craze that currently surrounds us. New platforms, and devices, create a sort of gold rush when they are announced. As technologies change quicker and quicker these gold rushes get shorter and shorter. I think it is obvious that as more apps are released and as more developers enter the marketplace, flawless common experiences will be required for apps to be successful. Things like sharing (Twitter, Facebook, Email) are likely to all assimilate as more open source modules for this are introduced.  I think an emerging market right now are applications based around accessories. Apple just this month rolled out iPhone <a title="Apple's iPod Touch Based Easy Pay Checkout System" href="http://www.appleinsider.com/articles/09/11/03/exclusive_look_at_apples_new_ipod_touch_based_easypay_checkout.html" target="_blank">accessories for checkout at Apple Stores</a>, along with <a title="Square Up Payment System" href="https://squareup.com/" target="_blank">several</a> <a title="Payware Mobile" href="http://www.paywaremobile.com/" target="_blank">others</a>. I imagine we will see things like universal remote adapters, fm transmitters, heath care accessories, scales, and gaming controllers. If these kinds of devices are introduced and gain some popularity it will help to solidify the iPhone in the marketplace, as accessories for any device are really a sort of investment in them.  In terms of development changes in 2010, I&#8217;m sure we will see SDK 4.0 being released at some point. I can&#8217;t speak to new features since they would all essentially be guesses, but I do see apple enhancing one specific type of operation in the next OS revision. A great new feature in OS 3.0 was the introduction of NSOperation and Core Data (Tutorial coming soon I promise!). These tools are Apple&#8217;s solution for simplifying the interface to SQLite and NSThreading. I could see apple adding even more abilities to these classes to make background processing even simpler. This could eventually lead to Apple letting the next iPhone run apps in the background like the <a title="Palm Pre Info" href="http://www.palm.com/us/products/phones/pre/" target="_blank">Palm Pre</a> and some <a title="Android running multiple=">Android</a> distributions.</p>
<h2><span style="color: #ff6600;">iCodeBlog</span></h2>
<p><span style="color: #000000;"><a href="http://icodeblog.com/wp-content/uploads/2010/01/logo_bigger.png"><img class="alignleft size-full wp-image-1662" title="logo_bigger" src="http://icodeblog.com/wp-content/uploads/2010/01/logo_bigger.png" alt="" width="73" height="73" /></a>iCodeBlog is going to be seeing a lot of changes in 2010 as well. We have been hard at work at rolling out a brand new look for the site as well as adding a could of extra new sections to help you guys get your apps made. We want to help our readers apply the skills that they are learning to real apps that get into the store. The new iCodeBlog will offer sections for developers to list their credentials and availability as well as a place for people to post prospective projects with descriptions, budgets and deadlines. We want to evolve into the number one place for iPhone developers to come to hone their skills and find work. </span></p>
<p><span style="color: #000000;">In order to facilitate this we will be putting a lot of work into making users and their profiles more integrated into the site. Comments will receive a significant update and we will be trying to do as many requested tutorials as we can. We are also very excited about iPhone OS 4.0 and whatever other goodies are shipped out from the mothership in Cupertino this year (See below). For now we will give a small glimpse into what we are thinking for iCodeBlog 2010.</span></p>
<p><span style="color: #000000;"><a href="http://icodeblog.com/wp-content/uploads/2010/01/video_blog.jpg"><img class="aligncenter size-full wp-image-1664" title="video_blog" src="http://icodeblog.com/wp-content/uploads/2010/01/video_blog.jpg" alt="" width="451" height="750" /></a><br />
</span></p>
<h2><span style="color: #ff6600;">The Tablet</span></h2>
<p><span style="color: #000000;">As I&#8217;m sure most of you have seen, tablet talk is hitting a <a title="New York Times - Design" href="http://www.nytimes.com/2010/01/04/arts/04iht-design4.html" target="_blank">fever</a> <a title="All Things Digital: Major Apple Announcement Jan. 27 " href="http://digitaldaily.allthingsd.com/20100104/major-apple-product-announcement/" target="_blank">pitch</a>. Apple&#8217;s stock the last few weeks is evidence enough that people think something is up in Cupertino. I&#8217;m not going to say whether or not I think there will be one. I want there to be one, but like everyone else I haven&#8217;t seen it, so I can&#8217;t say. With that said, lets assume something does come out. Lets for a moment dive into the hypothetical development market of the Apple Tablet.</span> First off some ground rules. Lets assume we have the 10.1 inch glass multi touch tablet everyone is predicting, similar to the <a title="JooJoo Pad" href="https://thejoojoo.com/" target="_blank">Joo Joo Pad</a>.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="338" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=8057291&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="600" height="338" src="http://vimeo.com/moogaloop.swf?clip_id=8057291&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/8057291">JooJoo Hands On Demo</a> from <a href="http://vimeo.com/user562128">Gizmodo</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>I&#8217;m sure that there is going to be some type of Apple flare, however for simplicities sake lets say a device with very similar hardware to the JooJoo Pad is released by Apple. Lets also assume that the device has some hybrid of OS X and iPhone OS, allowing for background processing and higher performance but using its own UI classes much like the iPhone. Here is what I see as the emerging markets as a result of a device like this.</p>
<h3><span style="color: #ff6600;">Make Reading Cool Again</span></h3>
<p>Many people when talking about this device deem it to be the &#8220;Kindle Killer&#8221;. The major difference between a device like this and the <a title="Kindle" href="http://www.amazon.com/Kindle-Amazons-Original-Wireless-generation/dp/B000FI73MA" target="_blank">Kindle</a> or the <a title="Barnes and Noble Nook" href="http://www.barnesandnoble.com/nook/" target="_blank">Nook</a> is that it would have an LCD of some type rather than the eInk employed in current eBook Readers. While I understand the advantage in terms of looking at <a title="Giz explains why there isn't a perfect ebook reader" href="http://gizmodo.com/5152092/giz-explains-why-there-isnt-a-perfect-ebook-reader" target="_blank">eInk compared to an LCD</a> on eye strain, an LCD will be able to present the media rich content we have become accustomed to on the internet much better than its eBook counterparts. Over the last few weeks many of these &#8220;tablet magazine&#8221; video mock ups have been coming to light. This is my personal favorite and I think it brings up a lot of interesting design ideas that we may begin seeing in 2010.  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="338" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7939946&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="600" height="338" src="http://vimeo.com/moogaloop.swf?clip_id=7939946&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/7939946">Sports Illustrated &#8211; Tablet Demo 1.5</a> from <a href="http://vimeo.com/thewonderfactory">The Wonderfactory</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>I see this experience as an elegant merger of the periodical and the internet. Magazines and their physical properties have an important role in history. Newspaper covers and magazine covers stand as markers of important moments in history. I don&#8217;t feel that websites have achieved this same position in our minds. Does anyone remember what the front page of NY Times look like on a certain day? The amount of content has skyrocketed, however the lasting impact of the content has suffered. I feel that the UI put forth in a device such as the tablet will be able to allow news outlets and other types of content generators to present their work more deliberately, and therefore make it more permanent in the minds of its viewers. The goal here is to present dynamic content in a permanent context. Sustain all the flexibility the web has made us expect, while presenting it in classical forms.</p>
<h2><a href="http://icodeblog.com/wp-content/uploads/2009/12/1.jpg"><img title="1" src="http://icodeblog.com/wp-content/uploads/2009/12/1.jpg" alt="" width="208" height="270" /></a><span style="font-weight: normal; font-size: 13px;"><img title="2" src="http://icodeblog.com/wp-content/uploads/2009/12/2.jpg" alt="" width="203" height="270" /><a style="text-decoration: none;" href="http://icodeblog.com/wp-content/uploads/2009/12/3.jpg"><img class="size-full wp-image-1619 aligncenter" title="3" src="http://icodeblog.com/wp-content/uploads/2009/12/3.jpg" alt="" width="215" height="270" /></a></span></h2>
<p>This new market is going to make a new kind of job opening for any type of service that presents content to its users. In 2009 we saw the emergence of apps. Many times apps were small utilities like <a title="Tapbots - Convertbot" href="http://tapbots.com/convertbot/" target="_blank">conversion</a> tools or <a title="LCD Clock" href="http://www.uuuu.to/app/lcdclock/index_e.html" target="_blank">timers</a>. But the vast majority of app (excluding games) are really just content delivery mechanisms. Take any news application for example. These are native iPhone apps, but more generally they are specialized views of the providers web content. When you open up the <a title="CNN iPhone Application: About" href="http://www.cnn.com/mobile/iphone/" target="_blank">CNN app</a> you are really just seeing the same content that is availabale on their website except they have been kind enough to make you pay $2.99 to see it in this iPhone specialized package (Not a rip on CNN BTW, they got the king of news apps IMHO).   <a href="http://icodeblog.com/wp-content/uploads/2009/12/2.jpg"></a><a href="http://icodeblog.com/wp-content/uploads/2009/12/2.jpg"></a><a href="http://icodeblog.com/wp-content/uploads/2009/12/2.jpg"></a><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="338" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=8217311&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="600" height="338" src="http://vimeo.com/moogaloop.swf?clip_id=8217311&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/8217311">Mag+</a> from <a href="http://vimeo.com/bonnier">Bonnier</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>The idea of a big high resolution touch screen is very alluring in terms of creating these new types of content views. Companies like <a title="Bonnier AB" href="http://www.bonnier.com/en" target="_blank">Bonnier AB</a> are investigating what types of software design could be used to emulate the physical experiences we had in the past. It seems reasonable that Apple could use its current 70/30 model from the app store and apply it to content like this, or possibly borrow ideas from the app store such as season subscriptions. As a developer this is the most exciting prospect for me.</p>
<p>To deliver content as complex as the kind shown in the concept Sport Illustrated video, Apple will need to create a ton of new UI elements for developers to be able to create dynamic applications rapidly. Overall I see a very important shift in the skills that a great tablet developer will need. There is going to be a big desire for developers who are able to walk the line of designer and developer. Magazines and newspapers for years have been increasing the amount of money invested into developers as their websites become as popular as the actual periodical they create. With this kind of outlet available, these organizations will be looking for hybrid talent. A successful digital magazine is going to require input from both developers and designers. As a result of this I see Apple introducing a highly revamped <a title="Interface Builder Wikipedia" href="http://en.wikipedia.org/wiki/Interface_Builder" target="_blank">Interface Builder</a>, essentially taking some of the key points from <a title="InDesign CS4" href="http://www.adobe.com/products/indesign/">InDesign</a> and <a title="Quark Designer" href="http://www.quark.com/" target="_blank">Quatrz</a>. While Interface Builder will need to take on some kind of print design functionality, that does not perfect suite the kind of software development I see occurring. The common print elements of yesteryear (Sidebars, Block Quotes, Photo, Captions) will need to be given some kind of internet like functionality to allow for this joining of print design and dynamic content. I see Apple using some of the ideas that it has already built into iWork as nice foundations for developers tools such as this. If you look at the &#8220;Smart Builds&#8221; that have been included in <a title="Keynote" href="http://www.apple.com/iwork/keynote/" target="_blank">Keynote</a>, I think we can see a nice glimpse into the future UI components Apple will make available to developers.</p>
<p>But without getting to far into the prediction zone, I think it is safe to say that if this tablet happens, developers will be best positioned with a solid layout/design background to include on their resumes. This type of device will require a heightened level of cooperation between the design and development talent of a company. The internet has always valued content of presentation, look at the <a title="Drudge Report" href="http://www.drudgereport.com/" target="_blank">Drudge Report</a> for instance. This device will be a new chapter in terms of users expectations on the quality of content; both quality of information and quality of presentation will be vital. The successful developer of 2010 should be studying up on their content presentation guidelines, popular graphic design looks and all these sweet digital magazine mockups! If a device like this picks up popularity in a similar way to the iPhone all content developers will eventually need their content to be &#8220;tablet enhanced&#8221;.</p>
<h3><span style="color: #ff6600;">Big Screen Gaming</span></h3>
<p><span style="color: #ff6600;"><span style="color: #000000;">A device like the tablet would allow for the touch control based games we have seen emerging over the last year to really mature. A few months back <a title="Illusion Labs" href="http://www.illusionlabs.com/" target="_blank">Illusion Labs</a> in conjunction with <a title="TouchTech" href="http://www.touchtech.se/en/" target="_blank">TouchTech</a> showed off a BIG screen multitouch demo of their games <a title="Touch Grind" href="http://www.touchgrind.com/" target="_blank">TouchGrind</a> and <a title="Illusion Labs: Sway" href="http://www.swaythegame.com/web/home.html" target="_blank">Sway</a> and I personally find the results amazing. A lot of times when I am playing games on my phone I find myself unable to be immerse in the experience because I am constantly blocking my view of the gameplay with my fingers. With a larger screen I think game developers would be able to work around this problem more effectively and create a new class of games that really take advantage of the unique input that multitouch allows. </span><br />
</span><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/RljkmXP-JX4&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hd=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/RljkmXP-JX4&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hd=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>There are certain gaming genres that are really going to gain a lot of value as more powerful multitouch devices and frameworks are released. <a title="Ubisoft" href="http://www.ubi.com/" target="_blank">Ubisoft</a> has this great promotional video for the new game Ruse that shows off some compelling looks at game play of a Real Time Strategy (RTS) game on a large multitouch screen; and a device like the tablet would be a great stepping stone for software like this and would be easy for developers to move the already incredibly popular iPhone RTS&#8217;s onto. I&#8217;m not much of a game developer myself but these two videos make me feel like video games are going to see a lot of benefit through the proliferation of larger, higher resolutions touch screen devices. People have been saying the Apple has <a title="Apple vs Nintendo vs Sony" href="http://news.gotgame.com/and-the-winner-is-apple-vs-nintendo-vs-sony/20270/" target="_blank">thrown the gauntlet</a> in the portable gaming wars and with a device like that tablet they are looking to really piss off the big time console manufacturers. It is going to be interesting if Apple would push this larger touch screen device in the gaming market as much as they have pushed the iPod Touch. If there was to be some development in terms of the integration of the two devices, say the iPhone acting as a controller for a game running on the touch, Apple would essentially be entering into a market with xBox and PS3.<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="299" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://blip.tv/play/gctb9bxNAg" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="299" src="http://blip.tv/play/gctb9bxNAg" allowfullscreen="true"></embed></object></p>
<h3><span style="color: #ff6600;">Mass Appeal</span></h3>
<p><span style="color: #000000;">So with all this said one large question does remain for this device. Can it really be a success in the way that the iPod and iPhone were? Everything I have referenced relies completely upon this thing having a major audience. If Apple only sells 1 million of these things this year they are going to be in some serious trouble. These high profile magazines, enhanced content and high budget games are only going to be made if there is an audience to consume the content. Can this &#8220;iSlate&#8221; really be the digital device to rule them all? The computer for the desk was incredible for a while but then became to immobile. The laptop was incredible for mobility but lack use on the move. The iPhone was incredible to use on the move but lacked power and functionality. Can the tablet conquer mobile usage and power. I have been pondering this for months and for some reason my mind keep wandering off to this one specific episode of South Park  in the fourth Season called &#8220;Trapper Keeper&#8221; (see below). The idea is Catmen gets the new Trapper Kepper that really kind of looks like a tablet. It can do all these crazy functions and even work with other devices. I guess currently the Adult trapper keeper is the laptop. It holds our notes, conversations, drawings, contacts, appointments; much like our school day trapper keeper did. Can Apple be making the real adult Trapper Keeper? My vote for the name is iKeeper.</span></p>
<p><span style="color: #000000;"><br />
</span></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/mGMpimHXIFM&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hd=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/mGMpimHXIFM&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hd=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Thanks for reading and happy coding!</p>
<p>Follow me on Twitter! <a title="Cruffenach's Twitter" href="http://www.twitter.com/cruffenach" target="_blank">@cruffenach</a> or contact me in comments.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2010/01/05/cocoa-development-in-2010/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>UITextField &#8211; A Complete API Overview</title>
		<link>http://icodeblog.com/2010/01/04/uitextfield-a-complete-api-overview/</link>
		<comments>http://icodeblog.com/2010/01/04/uitextfield-a-complete-api-overview/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 17:58:18 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[iPhone Coding]]></category>
		<category><![CDATA[iphone programming]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[UITextField]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1547</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2010/01/04/uitextfield-a-complete-api-overview/"><img align="left" hspace="5" width="150" src="http://icodeblog.com/wp-content/uploads/2009/12/screenshot_01.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>The UITextField is probably one of the most commonly used UI controls on the iPhone. It is the primary method of user input via the keyboard and provides a great deal of additional functionality.
With the success of our las API tutorial on NSArray, I thought I would do another walkthrough, this time on UITextField. I [...]]]></description>
			<content:encoded><![CDATA[<p style="clear: both;">The UITextField is probably one of the most commonly used UI controls on the iPhone. It is the primary method of user input via the keyboard and provides a great deal of additional functionality.</p>
<p>With the success of our las API tutorial on <a href="http://icodeblog.com/2009/08/26/objective-c-tutorial-nsarray/">NSArray</a>, I thought I would do another walkthrough, this time on UITextField. I will be explaining all of the properties for it as well as bringing up some functionality that you may not have known about.</p>
<h2>Text Attributes</h2>
<p style="clear: both;">The attributes have to do with the actual text inside of the UITextField.<br />
<style type="text/css"> table.api td {border:1px solid #777;} </style>
</p>
<table class="api" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>text</td>
<td>The text displayed in the UITextField</td>
</tr>
<tr>
<td>placeholder</td>
<td>The text that gets displayed prior to the user entering in anything. This text is usually a lighter color than the primary text to denote that it will be replaced.</td>
</tr>
<tr>
<td>font</td>
<td>The font of the text to be displayed. You can set it like this</td>
</tr>
<tr>
<td>textColor</td>
<td>The color of the text that is displayed</td>
</tr>
<tr>
<td>textAlignment</td>
<td>How the text is aligned in the UITextField. The possible values for this are UITextAlignmentLeft, UITextAlignmentRight, UITextAlignmentCenter</td>
</tr>
</tbody>
</table>
<p style="clear: both;">
<p style="clear: both;">Here are some examples of using these properties.</p>
<p style="clear: both;">

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Setting the text</span>
<span style="color: #002200;">&#91;</span>myTextField setText<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;This is some text!&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Setting the placeholder</span>
<span style="color: #002200;">&#91;</span>myTextField setPlaceholder<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Type text here&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Setting the font.</span>
<span style="color: #002200;">&#91;</span>myTextField setFont<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIFont fontWithName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Times New Roman&quot;</span> size<span style="color: #002200;">:</span><span style="color: #2400d9;">14</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Setting the text color</span>
<span style="color: #002200;">&#91;</span>myTextField setTextColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor blueColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Setting the text alignment</span>
<span style="color: #002200;">&#91;</span>myTextField setTextAlignment<span style="color: #002200;">:</span>UITextAlignmentCenter<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p style="clear: both;">
<p style="clear: both;"><img class="alignnone size-full wp-image-1570" style="display: inline; float: left; margin: 0 10px 10px 0;" src="http://icodeblog.com/wp-content/uploads/2009/12/screenshot_01.png" alt="" width="298" height="50" align="left" />Here is what the UITextField would look like after we update these properties.</p>
<p style="clear: both;"><img class="alignnone size-full wp-image-1571" style="display: inline; float: left; margin: 0 10px 10px 0;" title="screenshot_02" src="http://icodeblog.com/wp-content/uploads/2009/12/screenshot_02.png" alt="" width="298" height="52" align="left" /><br style="clear: both;" /></p>
<h2>Adjusting the size of the text in the UITextField</h2>
<p style="clear: both;">
<p style="clear: both;">
<p style="clear: both;">The text displayed in our UITextField can be dynamically sized based on the width of the UITextField. The benefit of this is all of the text being typed will be visible on the screen. It will shrink the text down until it reaches the default font size of 17. So, for this to make sense, you must set the font size of the UITextField to something larger than 17.</p>
<table class="api" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>adjustsFontSizeToFitWidth</td>
<td>Boolean value denoting whether to fit the font size to the width of the UITextField.</td>
</tr>
</tbody>
</table>
<p style="clear: both;">
<p style="clear: both;">Here is an example of using these properties.</p>
<p style="clear: both;">

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>myTextField setFont<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIFont fontWithName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Times New Roman&quot;</span> size<span style="color: #002200;">:</span><span style="color: #2400d9;">30</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>myTextField setAdjustsFontSizeToFitWidth<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p style="clear: both;">
<p style="clear: both;"><img class="alignnone size-full wp-image-1577" style="display: inline; float: left; margin: 0 10px 10px 0;" title="screenshot_03" src="http://icodeblog.com/wp-content/uploads/2009/12/screenshot_03.png" alt="" width="298" height="55"  />Here are some screenshots of the text shrinking when typing in the UITextField.</p>
<p style="clear: both;"><img class="alignnone size-full wp-image-1578" style="display: inline; float: left; margin: 0 10px 10px 0;" title="screenshot_04" src="http://icodeblog.com/wp-content/uploads/2009/12/screenshot_04.png" alt="" width="298" height="48" /></p>
<p style="clear: both;"><img class="alignnone size-full wp-image-1579" style="display: inline; float: left; margin: 0 10px 10px 0;" title="screenshot_05" src="http://icodeblog.com/wp-content/uploads/2009/12/screenshot_05.png" alt="" width="298" height="52"  /><br style="clear: both;" /></p>
<h2>Managing the editor&#8217;s behavior</h2>
<p style="clear: both;">
<p style="clear: both;">
<p style="clear: both;">These two properties are pretty straight forward.</p>
<table class="api" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>editing</td>
<td>Read-only boolean value letting you know if the user is currently editing the UITextField</td>
</tr>
<tr>
<td>clearsOnBeginEditing</td>
<td>Clears the text in the field every time the user begins to edit it.</td>
</tr>
</tbody>
</table>
<p style="clear: both;">
<p style="clear: both;">Not very exciting and probably doesn&#8217;t even deserve an example&#8230;</p>
<p style="clear: both;">
<p style="clear: both;">
<p style="clear: both;">
<h2>Setting the view&#8217;s background appearance</h2>
<p style="clear: both;">
<p style="clear: both;">
<p style="clear: both;">This group of properties defines how the UITextField will look. If you have ever seen a fancy input box, this is how they are doing it.</p>
<table  class="api" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>borderStyle</td>
<td>Defines the type of border for the UITextField. Possible choices are UITextBorderStyleNone, UITextBorderStyleLine, UITextBorderStyleBezel, and UITextBorderStyleRoundedRect. The default is UITextBorderStyleNone.</td>
</tr>
<tr>
<td>background</td>
<td>A UIImage representing the background image of the UITextField when it&#8217;s enabled. If this field is altered the borderStyle property is ignored.</td>
</tr>
<tr>
<td>backgroundDisabled</td>
<td>A UIImage representing the background image of the UITextField when it&#8217;s disabled.</td>
</tr>
</tbody>
</table>
<p style="clear: both;">
<p style="clear: both;">Here is are some example of using each of the border styles</p>
<p style="clear: both;">

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Border Style None</span>
<span style="color: #002200;">&#91;</span>myTextField setBorderStyle<span style="color: #002200;">:</span>UITextBorderStyleNone<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p style="clear: both;">
<p style="clear: both;"><img class="alignnone size-full wp-image-1635" style="display: inline; float: left; margin: 0 10px 10px 0;" title="screenshot_05" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_05.png" alt="" width="290" height="43" align="left" /></p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Border Style Line</span>
<span style="color: #002200;">&#91;</span>myTextField setBorderStyle<span style="color: #002200;">:</span>UITextBorderStyleLine<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p style="clear: both;">
<p style="clear: both;"><img class="alignnone size-full wp-image-1637" style="display: inline; float: left; margin: 0 10px 10px 0;" title="screenshot_03" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_03.png" alt="" width="288" height="41" align="left" /></p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Border Style Bezel</span>
<span style="color: #002200;">&#91;</span>myTextField setBorderStyle<span style="color: #002200;">:</span>UITextBorderStyleBezel<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p style="clear: both;">
<p style="clear: both;"><img class="alignnone size-full wp-image-1636" style="display: inline; float: left; margin: 0 10px 10px 0;" title="screenshot_02" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_02.png" alt="" width="291" height="42" align="left" /></p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Border Style Rounded Rect</span>
<span style="color: #002200;">&#91;</span>myTextField setBorderStyle<span style="color: #002200;">:</span>UITextBorderStyleRoundedRect<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p style="clear: both;">
<p style="clear: both;"><a class="image-link" href="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_04.png"><img class="alignnone size-full wp-image-1638" style="display: inline; float: left; margin: 0 10px 10px 0;" title="screenshot_04" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_04.png" alt="" width="288" height="41" align="left" /></a></p>
<p style="clear: both;"><a class="image-link" href="http://icodeblog.com/wp-content/uploads/2010/01/bg.png"><img class="alignnone size-full wp-image-1641" style="display: inline; float: left; margin: 0 10px 10px 0;" title="bg" src="http://icodeblog.com/wp-content/uploads/2010/01/bg.png" alt="" width="185" height="28" align="left" /></a>The border style is not terribly exciting. However, you can really spruce up your UITextFields using the background property. Here is an example of setting the background property to this image.</p>
<p style="clear: both;">

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">myTextField.textAlignment <span style="color: #002200;">=</span> UITextAlignmentCenter;
myTextField.textColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor whiteColor<span style="color: #002200;">&#93;</span>;
myTextField.borderStyle <span style="color: #002200;">=</span> UITextBorderStyleNone;
myTextField.background <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bg.png&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p style="clear: both;">
<p style="clear: both;"><img class="alignnone size-full wp-image-1642" style="display: inline; float: left; margin: 0 10px 10px 0;" title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_01.png" alt="" width="288" height="46" align="left" />and the result&#8230; Looks pretty good ehh? One GOTCHA that I want to point out here is, to get the background property to work correctly, you must set the boderStyle to anything other than UITextBorderStyleRoundedRect. Otherwise, the default UITextField will be displayed.<br />
Setting the view&#8217;s background appearance</p>
<p style="clear: both;">
<h2>Managing Overlay Views</h2>
<p>Another interesting way of customizing your UITextFields is to use an overlay. UITextField offers a left and right overlay for your UITextFields. Here are the properties:</p>
<table class="api" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>clearButtonMode</td>
<td>The circled X that gets displayed when typing. Used to clear out the text. Possible values: UITextFieldViewModeNever, UITextFieldViewModeWhileEditing, UITextFieldViewModeUnlessEditing, UITextFieldViewModeAlways</td>
</tr>
<tr>
<td>leftView</td>
<td>The view that appears to the left inside a UITextField. This could be something like a magnifying glass for search.</td>
</tr>
<tr>
<td>leftViewMode</td>
<td>Works like clearButtonMode, but toggles the leftView.</td>
</tr>
<tr>
<td>rightView</td>
<td>Same as leftView, except it aligns to the right.</td>
</tr>
<tr>
<td>rightViewMode</td>
<td>Same as leftViewMode but controls the rightView</td>
</tr>
</tbody>
</table>
<p>Let&#8217;s take a look at how adjusting the leftView works:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">UIImageView <span style="color: #002200;">*</span> myView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span> UIImageView  alloc <span style="color: #002200;">&#93;</span>  initWithImage <span style="color: #002200;">:</span>
		<span style="color: #002200;">&#91;</span>UIImage  imageNamed <span style="color: #002200;">:</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;wordpress.png&quot;</span> <span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>myTextField  setLeftView <span style="color: #002200;">:</span>myView<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span> myTextField   setLeftViewMode<span style="color: #002200;">:</span> UITextFieldViewModeAlways<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>myView release <span style="color: #002200;">&#93;</span>;</pre></div></div>

<p><img class="alignnone size-full wp-image-1651" title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2010/01/screenshot_011.png" alt="" width="291" height="44" /></p>
<p>As you can see, the text aligns after the image.  This is a very simple way to really spruce up your UITextFields.</p>
<p>The last thing we are going to discuss is showing and hiding the keyboard.</p>
<h2>Showing and Hiding The Keyboard</h2>
<p>To show the keyboard:</p>

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

<p>To hide the keyboard</p>

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

<p>Well, I hope you have enjoyed this tutorial on the <strong>UITextField</strong>.  I would love to see links to some interesting custom UITextFields in the comments, so please post them.  Thanks for reading and happy iCoding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2010/01/04/uitextfield-a-complete-api-overview/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Introduction to MapKit in iPhone OS 3.0 Part 2</title>
		<link>http://icodeblog.com/2009/12/22/introduction-to-mapkit-in-iphone-os-3-0-part-2/</link>
		<comments>http://icodeblog.com/2009/12/22/introduction-to-mapkit-in-iphone-os-3-0-part-2/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 18:53:56 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[MapKit]]></category>
		<category><![CDATA[MKMapView]]></category>
		<category><![CDATA[MKReverseGeocoder]]></category>
		<category><![CDATA[MKReverseGeocoderDelegate]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1558</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/12/22/introduction-to-mapkit-in-iphone-os-3-0-part-2/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/12/Screen-shot-2009-12-22-at-11.48.05-AM-150x150.png" class="alignleft wp-post-image tfe" alt="" title="Screen shot 2009-12-22 at 11.48.05 AM" /></a>Introduction
Back in September I posted a large post going over all the components required to implement the MapKit in your application. The MapKit is a framework introduced in iPhone OS 3.0 and allows developers to easily take advantage of Google&#8217;s mapping technology. In my first post I go over how to present a map as [...]]]></description>
			<content:encoded><![CDATA[<h1><span style="color: #ff6600;">Introduction</span></h1>
<p><span style="color: #000000;">Back in September I <a title="Introduction to MapKit in iPhone OS 3.0" href="http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/" target="_blank">posted a large post</a> going over all the components required to implement the MapKit in your application. The MapKit is a framework introduced in iPhone OS 3.0 and allows developers to easily take advantage of Google&#8217;s mapping technology. In my first post I go over how to present a map as well as annotate the map with custom badges to highlight points of interest. The MapKit also gives developers access to reverse geocoding services from Google which I will cover in this post.</span></p>
<h1><span style="color: #ff6600;">Reverse Geocoding</span></h1>
<p><span style="color: #000000;">A users location is defined by coordinates. When using the Core Location services, or specifying where a map should center its view, coordinates will be the units developers will be working with. This is all well and good for presenting mapping information visually but there is a whole other set of information that can be derived from a set of coordinates.</span></p>
<ul>
<li>Country</li>
<li>State</li>
<li>Zip Code</li>
<li>Address</li>
</ul>
<p>Google provides the service to translate any coordinate set to an MKPlacemark object. An MKPlacemark object contains properties to access all this information. Let&#8217;s look into the process of getting this object.</p>
<h2>Step 1</h2>
<p>The first thing you need to do is make a &#8220;View Based Application&#8221;. Now we need to is pick a set of coordinates we want to use. I have decided to use the address of Arizona State University.</p>
<p><strong>Longitude: -111.936619;</strong></p>
<p><strong>Latitude: 33.416199;</strong></p>
<p>Make your AppDelegates .m file look like this:</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: #a61390;">void</span><span style="color: #002200;">&#41;</span>applicationDidFinishLaunching<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIApplication <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>application <span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// Override point for customization after app launch</span>
    <span style="color: #002200;">&#91;</span>window addSubview<span style="color: #002200;">:</span>viewController.view<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>window makeKeyAndVisible<span style="color: #002200;">&#93;</span>;
&nbsp;
	CLLocationCoordinate2D coord;
	coord.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">111.936619</span>;
	coord.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">33.416199</span>;
&nbsp;
	MKReverseGeocoder <span style="color: #002200;">*</span>geocoder <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>MKReverseGeocoder alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>coord<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>geocoder setDelegate<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>geocoder start<span style="color: #002200;">&#93;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<h2>Step 2</h2>
<p>Now we need to implement the MKReverseGeocoderDelegate methods. There are only 2 delegate methods:</p>
<p>Called when an error occurs when fetching the reverse geocoder object</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: #a61390;">void</span><span style="color: #002200;">&#41;</span>reverseGeocoder<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>MKReverseGeocoder <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>geocoder 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</pre></div></div>

<p>Called when the ReverseGeocode object is successfully returned.</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: #a61390;">void</span><span style="color: #002200;">&#41;</span>reverseGeocoder<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>MKReverseGeocoder <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>geocoder didFindPlacemark<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>MKPlacemark <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>placemark</pre></div></div>

<h2>Step 3</h2>
<p>Now we have a MKPlacemark object to use. An MKPlacemark object conforms to the MKAnnotation protocol. So these objects could be added as annotations to an MKMapView. For more information on MKAnnotations reference <a title="Introduction to MapKit in iPhone OS 3.0" href="http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/">part 1</a>. The MKPlacemark object contains the following properties that you can access to use in your application.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/12/Screen-shot-2009-12-22-at-11.48.05-AM.png"><img class="aligncenter size-full wp-image-1563" title="Screen shot 2009-12-22 at 11.48.05 AM" src="http://icodeblog.com/wp-content/uploads/2009/12/Screen-shot-2009-12-22-at-11.48.05-AM.png" alt="" width="597" height="400" /></a></p>
<p>To see all of these values make the success delegate method look like this:</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: #a61390;">void</span><span style="color: #002200;">&#41;</span>reverseGeocoder<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>MKReverseGeocoder <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>geocoder didFindPlacemark<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>MKPlacemark <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>placemark
<span style="color: #002200;">&#123;</span>
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;The geocoder has returned: %@&quot;</span>, <span style="color: #002200;">&#91;</span>placemark addressDictionary<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>You should see this output:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #2400d9;">2009</span><span style="color: #002200;">-</span><span style="color: #2400d9;">12</span><span style="color: #002200;">-</span><span style="color: #2400d9;">22</span> <span style="color: #2400d9;">11</span><span style="color: #002200;">:</span><span style="color: #2400d9;">23</span><span style="color: #002200;">:</span><span style="color: #2400d9;">05.492</span> ReverseGeocoder<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">2591</span><span style="color: #002200;">:</span><span style="color: #2400d9;">207</span><span style="color: #002200;">&#93;</span> The geocoder has returned<span style="color: #002200;">:</span> <span style="color: #002200;">&#123;</span>
    City <span style="color: #002200;">=</span> Tempe;
    Country <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">&quot;United States&quot;</span>;
    CountryCode <span style="color: #002200;">=</span> US;
    FormattedAddressLines <span style="color: #002200;">=</span>     <span style="color: #002200;">&#40;</span>
        <span style="color: #bf1d1a;">&quot;200-206 E Lemon St&quot;</span>,
        <span style="color: #bf1d1a;">&quot;Tempe, AZ 85281&quot;</span>,
        USA
    <span style="color: #002200;">&#41;</span>;
    State <span style="color: #002200;">=</span> Arizona;
    Street <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">&quot;200-206 E Lemon St&quot;</span>;
    SubAdministrativeArea <span style="color: #002200;">=</span> Maricopa;
    SubThoroughfare <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">&quot;200-206&quot;</span>;
    Thoroughfare <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">&quot;E Lemon St&quot;</span>;
    ZIP <span style="color: #002200;">=</span> <span style="color: #2400d9;">85281</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/12/22/introduction-to-mapkit-in-iphone-os-3-0-part-2/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Introduction to MapKit in iPhone OS 3.0</title>
		<link>http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/</link>
		<comments>http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 23:40:08 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[MapKit]]></category>
		<category><![CDATA[MKMapView]]></category>
		<category><![CDATA[MKMapViewDelegate]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1297</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0012-150x150.png" class="alignleft wp-post-image tfe" alt="Introduction to MapKit on iPhone OS 3.001" title="Introduction to MapKit on iPhone OS 3.001" /></a>Introduction
Hello everyone. Welcome to another screencast. Today we will be looking into the MapKit, a new API&#8217;s made available by Apple in the iPhone OS 3.0 release. The MapKit allows simple access to the map seen in the maps application. Using GoogleMaps as its engine the map kit allows for a developer to make their [...]]]></description>
			<content:encoded><![CDATA[<h1><span style="color: #ff6600;">Introduction</span></h1>
<p><span style="color: #ff6600;"><span style="color: #000000;">Hello everyone. Welcome to another screencast. Today we will be looking into the MapKit, a new API&#8217;s made available by Apple in the iPhone OS 3.0 release. The MapKit allows simple access to the map seen in the maps application. Using GoogleMaps as its engine the map kit allows for a developer to make their own custom map interface to fit their own application. Today we will be reviewing the MapView as well as the Map Annotations that can be used to highlight points of interest in a map. We will create our own custom map app, along with custom annotations. Let&#8217;s dive in.</span></span></p>
<h2 style="font-size: 1.5em;"><span style="color: #000000;">Skill Level</span> <span style="color: #ff6600;">Intermediate</span></h2>
<p>This tutorial is one for people familiar with general Objective C development and introductory experience to the iPhone SDK. Knowledge of general Interface Builder usage and DataSource and Delegate methods are required.</p>
<h1 style="font-size: 2em;"><span style="color: #ff6600;">Screencast</span></h1>
<p>I film myself coding out the entire sample project for each post. I personally think going through the Screencast is the best way to learn. But feel free to look through the slides and text if that suites you better.</p>
<p><object width="600" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6597568&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6597568&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="375"></embed></object>
<p><a href="http://vimeo.com/6597568">Introduction to Map Kit on iPhone OS 3.0</a> from <a href="http://vimeo.com/user2008025">Collin Ruffenach</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h1 style="font-size: 2em;"><span style="color: #ff6600;">Source</span></h1>
<h3 style="font-size: 1.17em;"><span style="font-weight: normal;"><a title="iCodeBlogMapSource" href="http://icodeblog.com/wp-content/uploads/2009/09/iCodeMap.zip">iCodeBlogMap Source</a> </span></h3>
<h1 style="font-size: 2em;"><span style="color: #ff6600;">Tutorial</span></h1>
<p><img style="display: block; margin-left: auto; margin-right: auto; border: 0px initial initial;" title="Introduction to MapKit on iPhone OS 3.001" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0012.png" alt="Introduction to MapKit on iPhone OS 3.001" width="620" height="465" /></p>
<p><img style="display: block; margin-left: auto; margin-right: auto; border: 0px initial initial;" title="Introduction to MapKit on iPhone OS 3.002" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0021.png" alt="Introduction to MapKit on iPhone OS 3.002" width="620" height="465" /></p>
<p><a style="text-decoration: none;" href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0031.png"><img class="aligncenter size-full wp-image-1307" title="Introduction to MapKit on iPhone OS 3.003" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0031.png" alt="Introduction to MapKit on iPhone OS 3.003" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0041.png"><img class="aligncenter size-full wp-image-1308" title="Introduction to MapKit on iPhone OS 3.004" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0041.png" alt="Introduction to MapKit on iPhone OS 3.004" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0051.png"><img class="aligncenter size-full wp-image-1309" title="Introduction to MapKit on iPhone OS 3.005" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0051.png" alt="Introduction to MapKit on iPhone OS 3.005" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0061.png"><img class="aligncenter size-full wp-image-1309" title="Introduction to MapKit on iPhone OS 3.006" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0061.png" alt="Introduction to MapKit on iPhone OS 3.006" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0071.png"><img class="aligncenter size-full wp-image-1309" title="Introduction to MapKit on iPhone OS 3.007" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0071.png" alt="Introduction to MapKit on iPhone OS 3.007" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.008.png"><img class="aligncenter size-full wp-image-1312" title="Introduction to MapKit on iPhone OS 3.008" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.008.png" alt="Introduction to MapKit on iPhone OS 3.008" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.009.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.009" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.009.png" alt="Introduction to MapKit on iPhone OS 3.009" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.010.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.010" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.010.png" alt="Introduction to MapKit on iPhone OS 3.010" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.011.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.011" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.011.png" alt="Introduction to MapKit on iPhone OS 3.011" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.012.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.012" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.012.png" alt="Introduction to MapKit on iPhone OS 3.012" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.013.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.013" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.013.png" alt="Introduction to MapKit on iPhone OS 3.013" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.014.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.014" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.014.png" alt="Introduction to MapKit on iPhone OS 3.014" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.015.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.015" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.015.png" alt="Introduction to MapKit on iPhone OS 3.015" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.016.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.016" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.016.png" alt="Introduction to MapKit on iPhone OS 3.016" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.017.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.017" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.017.png" alt="Introduction to MapKit on iPhone OS 3.017" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.018.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.018" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.018.png" alt="Introduction to MapKit on iPhone OS 3.018" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.019.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.019" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.019.png" alt="Introduction to MapKit on iPhone OS 3.019" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.020.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.020" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.020.png" alt="Introduction to MapKit on iPhone OS 3.020" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.021.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.021" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.021.png" alt="Introduction to MapKit on iPhone OS 3.021" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.022.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.022" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.022.png" alt="Introduction to MapKit on iPhone OS 3.022" width="620" height="465" /></a></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #df0001;">
<h2><span style="color: #ff6600;">iCodeBlogMapViewController.h</span></h2>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;iCodeBlogAnnotation.h&quot;</span>
<span style="color: #6e371a;">#import &quot;iCodeBlogAnnotationView.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> iCodeMapViewController <span style="color: #002200;">:</span> UIViewController
<span style="color: #002200;">&#123;</span>
	IBOutlet UITableView <span style="color: #002200;">*</span>tableview;
	IBOutlet MKMapView <span style="color: #002200;">*</span>mapView;
	IBOutlet UIImageView <span style="color: #002200;">*</span>shadowImage;
<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> IBOutlet UITableView <span style="color: #002200;">*</span>tableview;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> IBOutlet MKMapView <span style="color: #002200;">*</span>mapView;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> IBOutlet UIImageView <span style="color: #002200;">*</span>shadowImage;
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>loadOurAnnotations;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.023.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.023" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.023.png" alt="Introduction to MapKit on iPhone OS 3.023" width="620" height="465" /></a></p>
<h2><span style="color: #ff6600;">iCodeBlogAnnoation.h</span></h2>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">typedef</span> <span style="color: #a61390;">enum</span> <span style="color: #002200;">&#123;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">	iCodeBlogAnnotationTypeApple <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>,
	iCodeBlogAnnotationTypeEDU <span style="color: #002200;">=</span> <span style="color: #2400d9;">1</span>,
	iCodeBlogAnnotationTypeTaco <span style="color: #002200;">=</span> <span style="color: #2400d9;">2</span>
<span style="color: #002200;">&#125;</span> iCodeMapAnnotationType;
&nbsp;
<span style="color: #a61390;">@interface</span> iCodeBlogAnnotation <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span>
<span style="color: #002200;">&#123;</span>
	CLLocationCoordinate2D coordinate;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>title;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>subtitle;
	iCodeMapAnnotationType annotationType;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic<span style="color: #002200;">&#41;</span> CLLocationCoordinate2D coordinate;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>title;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>subtitle;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic<span style="color: #002200;">&#41;</span> iCodeMapAnnotationType annotationType;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.024.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.024" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.024.png" alt="Introduction to MapKit on iPhone OS 3.024" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.025.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.025" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.025.png" alt="Introduction to MapKit on iPhone OS 3.025" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.026.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.026" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.026.png" alt="Introduction to MapKit on iPhone OS 3.026" width="620" height="465" /></a></p>
<h2><span style="color: #ff6600;">iCodeBlogAnnoation.m</span></h2>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@implementation</span> iCodeBlogAnnotation
&nbsp;
<span style="color: #a61390;">@synthesize</span> coordinate;
<span style="color: #a61390;">@synthesize</span> title;
<span style="color: #a61390;">@synthesize</span> subtitle;
<span style="color: #a61390;">@synthesize</span> annotationType;
&nbsp;
<span style="color: #002200;">-</span>init
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span>initWithCoordinate<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>CLLocationCoordinate2D<span style="color: #002200;">&#41;</span>inCoord
<span style="color: #002200;">&#123;</span>
	coordinate <span style="color: #002200;">=</span> inCoord;
	<span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.027.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.027" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.027.png" alt="Introduction to MapKit on iPhone OS 3.027" width="620" height="465" /></a></p>
<h2><span style="color: #ff6600;">iCodeBlogAnnoationView.h</span></h2>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> iCodeBlogAnnotationView <span style="color: #002200;">:</span> MKAnnotationView
<span style="color: #002200;">&#123;</span>
	UIImageView <span style="color: #002200;">*</span>imageView;
<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> UIImageView <span style="color: #002200;">*</span>imageView;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.028.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.028" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.028.png" alt="Introduction to MapKit on iPhone OS 3.028" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.029.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.029" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.029.png" alt="Introduction to MapKit on iPhone OS 3.029" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.030.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.030" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.030.png" alt="Introduction to MapKit on iPhone OS 3.030" width="620" height="465" /></a></p>
<h2 style="font-size: 1.5em;"><span style="color: #ff6600;">Images to Use</span></h2>
<p><img class="alignleft size-full wp-image-1380" title="AppleMarker" src="http://icodeblog.com/wp-content/uploads/2009/09/AppleMarker.png" alt="AppleMarker" width="70" height="57" /></p>
<p><span style="color: #ff6600;"><img class="alignleft" style="display: block; margin-left: auto; margin-right: auto; border: 0px initial initial;" title="SchoolMarker" src="http://icodeblog.com/wp-content/uploads/2009/09/SchoolMarker.png" alt="SchoolMarker" width="70" height="57" /></span></p>
<p><img class="alignleft" title="TacosMarker" src="http://icodeblog.com/wp-content/uploads/2009/09/TacosMarker.png" alt="TacosMarker" width="70" height="57" /></p>
<p><span style="color: #ff6600;"> </span></p>
<p><span style="color: #ff6600;"><br />
</span></p>
<p><span style="font-size: x-large;"><span><strong><span style="font-size: small;"><span style="font-weight: normal;"><br />
</span></span></strong></span></span></p>
<h2><span style="color: #ff6600;">iCodeBlogAnnoationView.m</span></h2>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &quot;iCodeBlogAnnotationView.h&quot;</span>
&nbsp;
<span style="color: #a61390;">@implementation</span> iCodeBlogAnnotationView
&nbsp;
<span style="color: #a61390;">@synthesize</span> imageView;
&nbsp;
<span style="color: #6e371a;">#define kHeight 40</span>
<span style="color: #6e371a;">#define kWidth  37</span>
<span style="color: #6e371a;">#define kBorder 2</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithAnnotation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span> <span style="color: #002200;">&#41;</span>annotation reuseIdentifier<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>reuseIdentifier
<span style="color: #002200;">&#123;</span>
	iCodeBlogAnnotation<span style="color: #002200;">*</span> myAnnotation <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>iCodeBlogAnnotation<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>annotation;
&nbsp;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>myAnnotation annotationType<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeApple<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithAnnotation<span style="color: #002200;">:</span>myAnnotation reuseIdentifier<span style="color: #002200;">:</span>reuseIdentifier<span style="color: #002200;">&#93;</span>;
		self.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, kWidth, kHeight<span style="color: #002200;">&#41;</span>;
		self.backgroundColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor clearColor<span style="color: #002200;">&#93;</span>;
&nbsp;
		imageView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImageView alloc<span style="color: #002200;">&#93;</span> initWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;AppleMarker.png&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
		imageView.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>kBorder, kBorder, kWidth <span style="color: #002200;">-</span> <span style="color: #2400d9;">2</span> <span style="color: #002200;">*</span> kBorder, kWidth <span style="color: #002200;">-</span> <span style="color: #2400d9;">2</span> <span style="color: #002200;">*</span> kBorder<span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#91;</span>self addSubview<span style="color: #002200;">:</span>imageView<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>myAnnotation annotationType<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeEDU<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithAnnotation<span style="color: #002200;">:</span>myAnnotation reuseIdentifier<span style="color: #002200;">:</span>reuseIdentifier<span style="color: #002200;">&#93;</span>;
		self.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, kWidth, kHeight<span style="color: #002200;">&#41;</span>;
		self.backgroundColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor clearColor<span style="color: #002200;">&#93;</span>;
&nbsp;
		imageView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImageView alloc<span style="color: #002200;">&#93;</span> initWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;SchoolMarker.png&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
		imageView.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>kBorder, kBorder, kWidth <span style="color: #002200;">-</span> <span style="color: #2400d9;">2</span> <span style="color: #002200;">*</span> kBorder, kWidth <span style="color: #002200;">-</span> <span style="color: #2400d9;">2</span> <span style="color: #002200;">*</span> kBorder<span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#91;</span>self addSubview<span style="color: #002200;">:</span>imageView<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>myAnnotation annotationType<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeTaco<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super initWithAnnotation<span style="color: #002200;">:</span>myAnnotation reuseIdentifier<span style="color: #002200;">:</span>reuseIdentifier<span style="color: #002200;">&#93;</span>;
		self.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span>, <span style="color: #2400d9;">0</span>, kWidth, kHeight<span style="color: #002200;">&#41;</span>;
		self.backgroundColor <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>UIColor clearColor<span style="color: #002200;">&#93;</span>;
&nbsp;
		imageView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImageView alloc<span style="color: #002200;">&#93;</span> initWithImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;TacosMarker.png&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
		imageView.frame <span style="color: #002200;">=</span> CGRectMake<span style="color: #002200;">&#40;</span>kBorder, kBorder, kWidth <span style="color: #002200;">-</span> <span style="color: #2400d9;">2</span> <span style="color: #002200;">*</span> kBorder, kWidth <span style="color: #002200;">-</span> <span style="color: #2400d9;">2</span> <span style="color: #002200;">*</span> kBorder<span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#91;</span>self addSubview<span style="color: #002200;">:</span>imageView<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #002200;">&#91;</span>imageView setContentMode<span style="color: #002200;">:</span>UIViewContentModeScaleAspectFill<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">return</span> self;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.031.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.031" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.031.png" alt="Introduction to MapKit on iPhone OS 3.031" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.032.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.032" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.032.png" alt="Introduction to MapKit on iPhone OS 3.032" width="620" height="465" /></a></p>
<h2><span style="color: #ff6600;">iCodeBlogMapViewController.m</span></h2>

<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: #a61390;">void</span><span style="color: #002200;">&#41;</span>loadOurAnnotations
<span style="color: #002200;">&#123;</span>
	CLLocationCoordinate2D workingCoordinate;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">40.763856</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">73.973034</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>appleStore1 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore1 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apple Store 5th Ave.&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore1 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apple's Flagship Store&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore1 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeApple<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>appleStore1<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">51.514298</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">0.141949</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>appleStore2 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore2 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apple Store St. Regent&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore2 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;London England&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore2 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeApple<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>appleStore2<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">35.672284</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">139.765702</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>appleStore3 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore3 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apple Store Giza&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore3 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Tokyo, Japan&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore3 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeApple<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>appleStore3<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">37.331741</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">122.030564</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>appleStore4 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore4 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apple Headquarters&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore4 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;The Mothership&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore4 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeApple<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>appleStore4<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">41.894518</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">87.624005</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>appleStore5 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore5 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apple Store Michigan Ave.&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore5 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Chicago, IL&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>appleStore5 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeApple<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>appleStore5<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">32.264977</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">110.944011</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>tacoShop1 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop1 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Nico's Taco Shop&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop1 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Tucson, AZ&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop1 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeTaco<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>tacoShop1<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">32.743242</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">117.181451</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>tacoShop2 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop2 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Lucha Libre Gourmet&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop2 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;San Diego, CA&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop2 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeTaco<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>tacoShop2<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">32.594987</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">117.060936</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>tacoShop3 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop3 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;El Ranchero Taco Shop&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop3 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Rocky Pointe, Mexico&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop3 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeTaco<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>tacoShop3<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">34.594859</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">58.384336</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>tacoShop4 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop4 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Taco Tequila Sangria S.A.&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop4 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Buneos Aires, Argentina&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop4 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeTaco<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>tacoShop4<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">38.240550</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">0.526509</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>tacoShop5 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop5 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Albertsma Taco&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop5 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Gran Alacant, Spain&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>tacoShop5 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeTaco<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>tacoShop5<span style="color: #002200;">&#93;</span>;	
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">33.419490</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">111.930563</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>school1 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school1 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Arizona State University&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school1 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Go Sun Devils&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school1 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeEDU<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>school1<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">35.087537</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">106.618184</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>school2 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school2 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;University of New Mexico&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school2 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Go Lobos&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school2 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeEDU<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>school2<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">40.730838</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">73.997498</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>school3 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school3 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;New York University&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school3 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;New York, NY&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school3 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeEDU<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>school3<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">51.753523</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">1.253171</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>school4 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school4 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Oxford University&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school4 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Oxford, England&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school4 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeEDU<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>school4<span style="color: #002200;">&#93;</span>;
&nbsp;
	workingCoordinate.latitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">22.131982</span>;
	workingCoordinate.longitude <span style="color: #002200;">=</span> <span style="color: #2400d9;">82.142302</span>;
	iCodeBlogAnnotation <span style="color: #002200;">*</span>school5 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotation alloc<span style="color: #002200;">&#93;</span> initWithCoordinate<span style="color: #002200;">:</span>workingCoordinate<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school5 setTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;India Institute of Technology&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school5 setSubtitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Delhi, India&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>school5 setAnnotationType<span style="color: #002200;">:</span>iCodeBlogAnnotationTypeEDU<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>mapView addAnnotation<span style="color: #002200;">:</span>school5<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p><a style="text-decoration: none;" href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.033.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.033" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.033.png" alt="Introduction to MapKit on iPhone OS 3.033" width="620" height="465" /></a></p>
<h2><span style="color: #ff6600;">iCodeblogMapViewController.m</span></h2>

<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>iCodeBlogAnnotationView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>mapView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>MKMapView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>mapView viewForAnnotation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span> <span style="color: #002200;">&#41;</span>annotation
<span style="color: #002200;">&#123;</span>
	iCodeBlogAnnotationView <span style="color: #002200;">*</span>annotationView <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// determine the type of annotation, and produce the correct type of annotation view for it.</span>
	iCodeBlogAnnotation<span style="color: #002200;">*</span> myAnnotation <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>iCodeBlogAnnotation <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>annotation;
&nbsp;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>myAnnotation.annotationType <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeApple<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> identifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apple&quot;</span>;
		iCodeBlogAnnotationView <span style="color: #002200;">*</span>newAnnotationView <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>iCodeBlogAnnotationView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>self.mapView dequeueReusableAnnotationViewWithIdentifier<span style="color: #002200;">:</span>identifier<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">nil</span> <span style="color: #002200;">==</span> newAnnotationView<span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			newAnnotationView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotationView alloc<span style="color: #002200;">&#93;</span> initWithAnnotation<span style="color: #002200;">:</span>myAnnotation reuseIdentifier<span style="color: #002200;">:</span>identifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
		annotationView <span style="color: #002200;">=</span> newAnnotationView;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>myAnnotation.annotationType <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeEDU<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> identifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;School&quot;</span>;
&nbsp;
		iCodeBlogAnnotationView <span style="color: #002200;">*</span>newAnnotationView <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>iCodeBlogAnnotationView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>self.mapView dequeueReusableAnnotationViewWithIdentifier<span style="color: #002200;">:</span>identifier<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">nil</span> <span style="color: #002200;">==</span> newAnnotationView<span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			newAnnotationView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotationView alloc<span style="color: #002200;">&#93;</span> initWithAnnotation<span style="color: #002200;">:</span>myAnnotation reuseIdentifier<span style="color: #002200;">:</span>identifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
		annotationView <span style="color: #002200;">=</span> newAnnotationView;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>myAnnotation.annotationType <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeTaco<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> identifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Taco&quot;</span>;
&nbsp;
		iCodeBlogAnnotationView <span style="color: #002200;">*</span>newAnnotationView <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>iCodeBlogAnnotationView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#91;</span>self.mapView dequeueReusableAnnotationViewWithIdentifier<span style="color: #002200;">:</span>identifier<span style="color: #002200;">&#93;</span>;
&nbsp;
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">nil</span> <span style="color: #002200;">==</span> newAnnotationView<span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			newAnnotationView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>iCodeBlogAnnotationView alloc<span style="color: #002200;">&#93;</span> initWithAnnotation<span style="color: #002200;">:</span>myAnnotation reuseIdentifier<span style="color: #002200;">:</span>identifier<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
		annotationView <span style="color: #002200;">=</span> newAnnotationView;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #002200;">&#91;</span>annotationView setEnabled<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>annotationView setCanShowCallout<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">return</span> annotationView;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.034.png"><img class="aligncenter size-full wp-image-1313" title="Introduction to MapKit on iPhone OS 3.034" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.034.png" alt="Introduction to MapKit on iPhone OS 3.034" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0351.png"><img class="aligncenter size-full wp-image-1349" title="Introduction to MapKit on iPhone OS 3.035" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0351.png" alt="Introduction to MapKit on iPhone OS 3.035" width="620" height="465" /></a></p>
<h2><span style="color: #ff6600;">iCodeBlogMapViewController.m</span></h2>

<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>NSInteger<span style="color: #002200;">&#41;</span>numberOfSectionsInTableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">return</span> <span style="color: #2400d9;">3</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p><a style="text-decoration: none;" href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0361.png"><img class="aligncenter size-full wp-image-1350" title="Introduction to MapKit on iPhone OS 3.036" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0361.png" alt="Introduction to MapKit on iPhone OS 3.036" width="620" height="465" /></a></p>
<h2><span style="color: #ff6600;">iCodeBlogMapViewController.m</span></h2>

<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>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 titleForHeaderInSection<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>section</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>section <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeApple<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">return</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apple Markers&quot;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>section <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeEDU<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">return</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Schools&quot;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>section <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeTaco<span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">return</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Taco Shops&quot;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">return</span> <span style="color: #a61390;">nil</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0371.png"><img class="aligncenter size-full wp-image-1351" title="Introduction to MapKit on iPhone OS 3.037" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0371.png" alt="Introduction to MapKit on iPhone OS 3.037" width="620" height="465" /></a><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0381.png"></a></p>
<h2><span style="color: #ff6600;">iCodeBlogMapViewController.m</span></h2>

<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>NSInteger<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 numberOfRowsInSection<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>NSInteger<span style="color: #002200;">&#41;</span>section
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #2400d9;">5</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0381.png"><img class="aligncenter size-full wp-image-1352" title="Introduction to MapKit on iPhone OS 3.038" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0381.png" alt="Introduction to MapKit on iPhone OS 3.038" width="620" height="465" /></a><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0391.png"></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0391.png"><img class="aligncenter size-full wp-image-1353" title="Introduction to MapKit on iPhone OS 3.039" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0391.png" alt="Introduction to MapKit on iPhone OS 3.039" width="620" height="465" /></a></p>
<h2><span style="color: #ff6600;">iCodeBlogMapViewController.m</span></h2>

<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>UITableViewCell <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UITableView <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSIndexPath</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">static</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>CellIdentifier <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Cell&quot;</span>;
&nbsp;
    UITableViewCell <span style="color: #002200;">*</span>cell <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200;">:</span>CellIdentifier<span style="color: #002200;">&#93;</span>;
&nbsp;
	<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>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #400080;">NSMutableArray</span> <span style="color: #002200;">*</span>annotations <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableArray</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>indexPath.section <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span>iCodeBlogAnnotation <span style="color: #002200;">*</span>annotation <span style="color: #a61390;">in</span> <span style="color: #002200;">&#91;</span>mapView annotations<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>annotation annotationType<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeApple<span style="color: #002200;">&#41;</span>
			<span style="color: #002200;">&#123;</span>
				<span style="color: #002200;">&#91;</span>annotations addObject<span style="color: #002200;">:</span>annotation<span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#125;</span>
		<span style="color: #002200;">&#125;</span>
&nbsp;
		cell.textLabel.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>annotations objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span> title<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>indexPath.section <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span>iCodeBlogAnnotation <span style="color: #002200;">*</span>annotation <span style="color: #a61390;">in</span> <span style="color: #002200;">&#91;</span>mapView annotations<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>annotation annotationType<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeEDU<span style="color: #002200;">&#41;</span>
			<span style="color: #002200;">&#123;</span>
				<span style="color: #002200;">&#91;</span>annotations addObject<span style="color: #002200;">:</span>annotation<span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#125;</span>
		<span style="color: #002200;">&#125;</span>		
&nbsp;
		cell.textLabel.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>annotations objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span> title<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>indexPath.section <span style="color: #002200;">==</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span>iCodeBlogAnnotation <span style="color: #002200;">*</span>annotation <span style="color: #a61390;">in</span> <span style="color: #002200;">&#91;</span>mapView annotations<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>annotation annotationType<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> iCodeBlogAnnotationTypeTaco<span style="color: #002200;">&#41;</span>
			<span style="color: #002200;">&#123;</span>
				<span style="color: #002200;">&#91;</span>annotations addObject<span style="color: #002200;">:</span>annotation<span style="color: #002200;">&#93;</span>;
			<span style="color: #002200;">&#125;</span>
		<span style="color: #002200;">&#125;</span>
&nbsp;
		cell.textLabel.text <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>annotations objectAtIndex<span style="color: #002200;">:</span>indexPath.row<span style="color: #002200;">&#93;</span> title<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #a61390;">return</span> cell;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0401.png"><img class="aligncenter size-full wp-image-1354" title="Introduction to MapKit on iPhone OS 3.040" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0401.png" alt="Introduction to MapKit on iPhone OS 3.040" width="620" height="465" /></a></p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0411.png"><img class="aligncenter size-full wp-image-1355" title="Introduction to MapKit on iPhone OS 3.041" src="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0411.png" alt="Introduction to MapKit on iPhone OS 3.041" width="620" height="465" /></a><a href="http://icodeblog.com/wp-content/uploads/2009/09/Introduction-to-MapKit-on-iPhone-OS-3.0012.png"></a></p>
<h2><span style="color: #ff6600;">iCodeBlogMapViewController.m</span></h2>

<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: #a61390;">void</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 didSelectRowAtIndexPath<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSIndexPath</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>indexPath
<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span>iCodeBlogAnnotation <span style="color: #002200;">*</span>annotation <span style="color: #a61390;">in</span> <span style="color: #002200;">&#91;</span>mapView annotations<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>tableView cellForRowAtIndexPath<span style="color: #002200;">:</span>indexPath<span style="color: #002200;">&#93;</span> textLabel<span style="color: #002200;">&#93;</span> text<span style="color: #002200;">&#93;</span> isEqualToString<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>annotation title<span style="color: #002200;">&#93;</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>mapView setRegion<span style="color: #002200;">:</span>MKCoordinateRegionMake<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>annotation coordinate<span style="color: #002200;">&#93;</span>, MKCoordinateSpanMake<span style="color: #002200;">&#40;</span>.01, .01<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span> animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Special Deal For iCodeBlog Readers On An Invisible Shield</title>
		<link>http://icodeblog.com/2009/12/10/special-deal-for-icodeblog-readers-on-an-invisible-shield/</link>
		<comments>http://icodeblog.com/2009/12/10/special-deal-for-icodeblog-readers-on-an-invisible-shield/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 20:00:00 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1538</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/12/10/special-deal-for-icodeblog-readers-on-an-invisible-shield/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>The site invisibleskinz.com has decided to give iCodeBlog readers a 20% discount on the Invisible Shield for the iPhone and iPod Touch.]]></description>
			<content:encoded><![CDATA[<p>The site <a href="http://www.invisibleskinz.com/">invisibleskinz.com</a> has decided to give iCodeBlog readers a 20% discount on the Invisible Shield for the iPhone and iPod Touch.</p>
<h3>Promo code icode20</h3>
<p>
For those of you who don&#8217;t know what an Invisible Shield is, it&#8217;s a very thin film that covers your device to protect it from scratches and dammage.  They were kind enough to send me one to demo, and I freakin love it.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/jnuD5sJ9A8k&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jnuD5sJ9A8k&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>I&#8217;m sort of an odd person in the fact that I&#8217;m incredibly anal when it comes to scratches on my electronics.  I have taken an iPhone back to the store because there were a couple tiny &#8220;specks&#8221; under the screen before (crazy right?).</p>
<p>So, as you can imagine, an Invisible Shield is a perfect product for me.  I know this whole thing sounds like a lame sales pitch because I got a free one, but I can&#8217;t stress enough how cool these things are.  So, feel free to ream me in the comments, but I totally stand by this product.</p>
<p>And to top it off, all Invisible Shields have a life time warrantee. (I&#8217;m on my 3rd as they tend to peel off if you use them without an iPhone case).</p>
<p>So go get your discounted <a href="http://www.invisibleskinz.com/">Invisible Shield</a>.</p>
<h3>Promo code icode20</h3>
<p>
<b>Disclaimer:</b><br />
We accepted one demo product from the company for our review. We have no business relationship with the company nor make money from this review or their sales.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/12/10/special-deal-for-icodeblog-readers-on-an-invisible-shield/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The iPhone is Bad at Keeping Secrets</title>
		<link>http://icodeblog.com/2009/12/05/the-iphone-is-bad-at-keeping-secrets/</link>
		<comments>http://icodeblog.com/2009/12/05/the-iphone-is-bad-at-keeping-secrets/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 23:45:52 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1517</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/12/05/the-iphone-is-bad-at-keeping-secrets/"><img align="left" hspace="5" width="150" src="http://icodeblog.com/wp-content/uploads/2009/12/newton-virus-objectsq-150x150.jpg" class="alignleft wp-post-image tfe" alt="newton-virus-objectsq" title="newton-virus-objectsq" /></a>Today an article from TaranFx has been making the rounds talking about a new open source application called SpyPhone that highlights all of the &#8220;information vulnerabilities&#8221; within the current iPhone SDK. You can check out the article here:
SpyPhone App Steals Personal Data from ALL iPhones
Everyone has probably heard of the problems some users with jailbroken [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://icodeblog.com/wp-content/uploads/2009/12/newton-virus-objectsq.jpg"><img class="alignleft size-thumbnail wp-image-1519" title="newton-virus-objectsq" src="http://icodeblog.com/wp-content/uploads/2009/12/newton-virus-objectsq-150x150.jpg" alt="newton-virus-objectsq" width="150" height="150" /></a>Today an article from TaranFx has been making the rounds talking about a new open source application called SpyPhone that highlights all of the &#8220;information vulnerabilities&#8221; within the current iPhone SDK. You can check out the article here:</p>
<p><a title="SpyPhone App Steals Personal Data from ALL iPhones" href="http://www.taranfx.com/blog/spyphone-app-steals-personal-data-from-all-iphones" target="_blank">SpyPhone App Steals Personal Data from ALL iPhones</a></p>
<p>Everyone has probably heard of the problems some users with jailbroken iPhone have been experiencing. Without the boundaries in place from the SDK many users phones have been held <a title="Jailbroken iPhones Being Held Hostage" href="http://arstechnica.com/apple/news/2009/11/dutch-hacker-holds-jailbroken-iphones-hostage-for-5.ars">hostage</a> by malicious applications taking advantage of the default root password. This application, unlike the others we have heard about, uses only public portions of the API to get all the info it displays. The app displays:</p>
<ol>
<li>Email Accounts</li>
<li>Wi-Fi Networks</li>
<li>Phone Usage Info and History</li>
<li>Location Information</li>
<li>Safari Searches</li>
<li>YouTube Searches, History and Bookmarks</li>
<li>Photos</li>
<li>Address Book Data</li>
<li>Keyboard Cache</li>
</ol>
<p>While this is a lengthy list I think it is important not to take the easy road of yelling about security, privacy or whatever else and instead really look at how the app gets all this stuff. SpyPhone&#8217;s source can be downloaded at it&#8217;s <a title="SpyPhone's Git Hub" href="http://github.com/nst/spyphone/">git hub</a> and you can see for yourself how all the magic happens. With a quick look at the source the secret to this application is discovered. The iPhone contains many folders like your Macintosh Computer. Many of these folders are familiar sounding&#8230;&#8221;Applications&#8221;, &#8220;Library&#8221;, &#8220;Root&#8221;. If you have the SDK installed on your computer you can look at these folders as the iPhone simulator uses them as well. They are located at</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">~<span style="color: #002200;">/</span>Library<span style="color: #002200;">/</span>Application Support<span style="color: #002200;">/</span>iPhone Simulator<span style="color: #002200;">/</span>User</pre></div></div>

<p>This is where the iPhone keeps all of your data. Going back to SpyPhone&#8217;s code, the secret is taking advantage of these folders and the files the contain. If you go a little further into your iPhone Simulator folders you will find:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">~<span style="color: #002200;">/</span>Library<span style="color: #002200;">/</span>Application Support<span style="color: #002200;">/</span>iPhone Simulator<span style="color: #002200;">/</span>User<span style="color: #002200;">/</span>Library<span style="color: #002200;">/</span>Preferences<span style="color: #002200;">/</span></pre></div></div>

<p>In here there are tons of com.apple.SOMETHING.plist files. These files most of the surprising data that SpyPhone is able to grab. Some of it is facilitated by other parts of the SDK (Address Book Access, Photos), but the minor personal information can be found here. He grabs the info using code such as:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>path <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;/Library/Preferences/SystemConfiguration/com.apple.wifi.plist&quot;</span>;
&nbsp;
<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>dict <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithContentsOfFile<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>dict<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span>;
&nbsp;
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>a <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>dict valueForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;List of known networks&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>a<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">return</span>;</pre></div></div>

<p><span style="color: #000000;"> </span></p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 470px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">NSString *path = @&#8221;/Library/Preferences/SystemConfiguration/com.apple.wifi.plist&#8221;;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 470px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 470px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">if(!dict) return;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 470px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">NSArray *a = [dict valueForKey:@"List of known networks"];</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 470px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">
<p>if(!a) return;</p></div>
<p>This line for instance would create an array with all the known networks for the phone the application is being run on. While this is a little concerning I don&#8217;t think this is anything to make a big stink out of.  First off I know for a fact Apple gladly rejects applications sniffing around in here. One positive note of having Apple as an overlord is that they really do know every detail about the SDK, and are able to stop applications that abuse the SDK before they get on the store.</p>
<p>But this application brings up the larger issue of the mysterious App Store Approval process. It is incredible that admission to the worlds fastest growing software marketplace is such a mystery. All the code to grab the &#8220;sensitive&#8221; information that SpyPhone can occur with the user having no knowledge, and while I am sure that Apple has ways of testing these apps and monitoring their access to these PLISTS, I could easily imagine having an application that has that ability but does not execute the ability till I know it is in the app store.</p>
<p>For instance, if I had a small XML Doc online specifying whether to run the method to grab all the users information and had it set to NO for the approval process  and upon getting submitted changed the XML to say YES. I could begin collecting info on all the users who launch my app and the approvers in the App Store would never have seen it. So although I think Apple has a very good handle on how to root out malware, I&#8217;m sure there could be many ways to get around it. So I come to my final question, would you rather not have apps be able to use any of this info? No photos, no addresses, no wi-fi examination applications, limited in app mail. Lots of the functions that makes the iPhone awesome are wrapped up in these &#8220;security holes&#8221;. So what do you guys think? Should Apple close off access to at least the system PLISTS or is this making mountains over mole hills?</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/12/05/the-iphone-is-bad-at-keeping-secrets/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>iPhone Coding Tutorial &#8211; In Application Emailing</title>
		<link>http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/</link>
		<comments>http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 04:45:07 +0000</pubDate>
		<dc:creator>AppStoreMod</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1488</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/"><img align="left" hspace="5" width="150" src="http://icodeblog.com/wp-content/uploads/2009/11/IMG_0001.PNG" class="alignleft wp-post-image tfe" alt="IMG_0001" title="" /></a>A lot of applications you see have an email button. When you click it then it will leave the application and take you to the Mail application. It can get really annoying leaving the application and then going back in after your done sending the email. This is just a great way to show off [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-1489 alignleft" src="http://icodeblog.com/wp-content/uploads/2009/11/IMG_0001.PNG" alt="IMG_0001" width="157" height="235" />A lot of applications you see have an email button. When you click it then it will leave the application and take you to the Mail application. It can get really annoying leaving the application and then going back in after your done sending the email. This is just a great way to show off your app and make your app look more professional and make it easier on the user by filling in the To and Subject for them. They are also able to change the From to whatever email then want you to receive an email from just like you can do in the Mail app. So todays tutorial is gonna show you how to email within your application. We will be using the MessageUI framework and we will also include an attachment in the email. Theres a screenshot to the left of how it will look.<span id="more-1488"></span></p>
<p>So lets get started&#8230;</p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">1. Create A New View Based Application</span><br />
You can name yours whatever you want, in the tutorial I will be referring it as the NameViewControllers.<br />
<span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px"> </span></p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">2. Import The Frameworks</span></p>
<p>The first thing we need to do is import the framework. So go to your Frameworks folder in the Files In Pain section on the left. Open the folder and right click one of the frameworks and click &#8220;Reveal In Finder.&#8221; Heres a screenshot on what you should do.</p>
<p><img class="aligncenter size-full wp-image-1491" src="http://icodeblog.com/wp-content/uploads/2009/11/Screen-shot-2009-11-18-at-7.58.04-PM.png" alt="Screen shot 2009-11-18 at 7.58.04 PM" width="310" height="96" /></p>
<p>Go ahead and look for the &#8220;MessageUI.framework&#8221; and highlight it then drag it into your frameworks folder. Make sure that when you click Add on the thing that makes sure you want to import it that &#8220;Copy items into destination group&#8217;s folder (if needed)&#8221; is not check. Thats a very important step or you will have big time problems and you do this with any frameworks you would ever use in the future.</p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">3. Implementing The Code</span></p>
<p>Now that we have imported the framework lets get into some coding. So go ahead and jump in the NameViewController.H and make an IBAction for a button. Then copy that code and paste it in the NameViewController.M with curly brackets. Also make sure to add the button in Interface Builder and link it up with a Touch Up Inside method. You guys are at the point to knowing how to hook up actions and dragging stuff into Interface Builder. After that we want to on the top of the NameViewController.h import the framework. So on the top do #import &#8220;MessageUI/MessageUI.h&#8221; and the reason why we do this is because we must import out MessageUI framework to make calls to the associated header files. Now we need to also put in the delegate protocols for this framework. @interface NameViewController: UIViewController do this code &lt;MFMailComposeViewControllerDelegate, UINavigationControllerDelegate&gt;. Heres the code here for the NameViewController.H<span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px"> </span></p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #dd0005"><span style="color: #7d4625">#import </span>&lt;MessageUI/MessageUI.h&gt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span style="color: #c800a7">@interface</span> MailComposerViewController : UIViewController</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">&lt;MFMailComposeViewControllerDelegate,UINavigationControllerDelegate&gt;  {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00"><span style="color: #000000">-(<span style="color: #c800a7">IBAction</span>)pushEmail;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #c800a7">@end</p>
</blockquote>
<div><span style="font-family: Menlo, 'Times New Roman', 'Bitstream Charter', Times, serif;color: #c800a7"><span style="line-height: normal;font-size: small"><br />
</span></span></div>
<p>Now after your done with the .H jump into the .M viewcontroller. Now in your button action code do this:</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">-(<span style="color: #c800a7">IBAction</span>)pushEmail {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #7b1caf"><span style="color: #000000"><span> </span></span>MFMailComposeViewController<span style="color: #000000"> *mail = [[</span>MFMailComposeViewController<span style="color: #000000"> </span><span style="color: #470086">alloc</span><span style="color: #000000">] </span><span style="color: #470086">init</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #7b1caf"><span style="color: #000000"><span> </span>mail.</span>mailComposeDelegate<span style="color: #000000"> = </span><span style="color: #c800a7">self</span><span style="color: #000000">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #7b1caf"><span style="color: #000000"><span> </span></span><span style="color: #c800a7">if</span><span style="color: #000000"> ([</span>MFMailComposeViewController<span style="color: #000000"> </span><span style="color: #470086">canSendMail</span><span style="color: #000000">]) {</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00"><span style="color: #000000"><span> </span></span>//Setting up the Subject, recipients, and message body.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span>[mail </span>setToRecipients<span style="color: #000000">:[</span><span style="color: #7b1caf">NSArray</span><span style="color: #000000"> </span>arrayWithObjects<span style="color: #000000">:</span><span style="color: #dd0005">@"email@email.com"</span><span style="color: #000000">,</span><span style="color: #c800a7">nil</span><span style="color: #000000">]];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #dd0005"><span style="color: #000000"><span> </span>[mail </span><span style="color: #470086">setSubject</span><span style="color: #000000">:</span>@"Subject of Email"<span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span>[mail </span>setMessageBody<span style="color: #000000">:</span><span style="color: #dd0005">@"Message of email"</span><span style="color: #000000"> </span>isHTML<span style="color: #000000">:</span><span style="color: #c800a7">NO</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00"><span style="color: #000000"><span> </span></span>//Present the mail view controller</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span>[</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>presentModalViewController<span style="color: #000000">:mail </span>animated<span style="color: #000000">:</span><span style="color: #c800a7">YES</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00"><span style="color: #000000"><span> </span></span>//release the mail</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>[mail <span style="color: #470086">release</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00">//This is one of the delegate methods that handles success or failure</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #008c00">//and dismisses the mail</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">- (<span style="color: #c800a7">void</span>)mailComposeController:(<span style="color: #7b1caf">MFMailComposeViewController</span>*)controller didFinishWithResult:(<span style="color: #470086">MFMailComposeResult</span>)result error:(<span style="color: #7b1caf">NSError</span>*)error</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span>[</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>dismissModalViewControllerAnimated<span style="color: #000000">:</span><span style="color: #c800a7">YES</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span></span><span style="color: #c800a7">if</span><span style="color: #000000"> (result == </span>MFMailComposeResultFailed<span style="color: #000000">) {</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"><span> </span></span><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> *alert = [[</span><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> </span>alloc<span style="color: #000000">] </span>initWithTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Message Failed!&#8221;</span><span style="color: #000000"> </span>message<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Your email has failed to send&#8221;</span><span style="color: #000000"> </span>delegate<span style="color: #000000">:</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>cancelButtonTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Dismiss&#8221;</span><span style="color: #000000"> </span>otherButtonTitles<span style="color: #000000">:</span><span style="color: #c800a7">nil</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>[alert <span style="color: #470086">show</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>[alert <span style="color: #470086">release</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">}</p>
</blockquote>
<div><span style="font-family: Menlo, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size: small"><span style="line-height: normal"><br />
</span></span></div>
<p>What if we wanted to include an image attachment to the email? Well its quite simple. Just add this to the code right under the part where you set up the Recipient, Subject, and the Message.</p>
<blockquote>
<p style="font: normal normal normal 11px/normal Menlo;margin: 0px"><span style="color: #7b1caf">UIImage</span> *pic = [<span style="color: #7b1caf">UIImage</span> <span style="color: #470086">imageNamed</span>:<span style="color: #dd0005">@"Funny.png"</span>];</p>
<p style="font: normal normal normal 11px/normal Menlo;margin: 0px"><span style="color: #7b1caf">NSData</span> *exportData = <span style="color: #470086">UIImageJPEGRepresentation</span>(pic ,<span style="color: #4100e0">1.0</span>);</p>
<p style="font: normal normal normal 11px/normal Menlo;color: #470086;margin: 0px"><span style="color: #000000">[mail </span>addAttachmentData<span style="color: #000000">:exportData </span>mimeType<span style="color: #000000">:</span><span style="color: #dd0005">@"image/jpeg"</span><span style="color: #000000"> </span>fileName<span style="color: #000000">:</span><span style="color: #dd0005">@"Picture.jpeg"</span><span style="color: #000000">];</span></p>
</blockquote>
<p>Now we are setting up the MailComposer in the first part of the code in the action. Then we call a didFinishWithResult method where we are setting up if the email fails or sends. Also it sets up a Cancel button for you so we have to call the dismiss method so that it works. In the attachment code just edit the imageNamed:@&#8221;" with your images name.That is basically it! The source code is below for the people that just doesn&#8217;t wanna copy and paste or type&#8230; I am just jking with you guys. Happy iCoding!</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/11/InApplicationEmailing1.zip">iPhone Tutorial &#8211; In Application Emailing</a></p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>iPhone In Action Book &#8211; Free Chapter Downloads</title>
		<link>http://icodeblog.com/2009/11/11/iphone-in-action-book-free-chapter-downloads/</link>
		<comments>http://icodeblog.com/2009/11/11/iphone-in-action-book-free-chapter-downloads/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 21:28:25 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[iPhone Articles]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone books]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1480</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/11/11/iphone-in-action-book-free-chapter-downloads/"><img align="left" hspace="5" width="150" src="http://brandontreb.com/wp-content/uploads/2009/11/Trebitowski-iPhone-2E-1-1.png" class="alignleft wp-post-image tfe" alt="Trebitowski-iPhone-2E-1-1" title="Trebitowski-iPhone-2E-1-1" /></a><a href="http://manning.com/">Manning Publishing</a> has started their MEAP (Manning Early Access Program) for the book I am working on.  What this means for you is FREE DOWNLOADS.  There is currently only one chapter available, but there will be more as the book progresses.

The chapter currently available is about audio recording and playback.  It goes into detail about the AVAudio frameworks as well as the MPMediaPlayer.]]></description>
			<content:encoded><![CDATA[<div id="attachment_559" class="wp-caption aligncenter" style="width: 460px"><a href="http://manning.com/trebitowski/"><img class="size-full wp-image-559 " title="Trebitowski-iPhone-2E-1-1" src="http://brandontreb.com/wp-content/uploads/2009/11/Trebitowski-iPhone-2E-1-1.png" alt="Trebitowski-iPhone-2E-1-1" width="450" height="564" /></a><p class="wp-caption-text">iPhone In Action 2nd Edition</p></div>
<p><a href="http://manning.com/">Manning Publishing</a> has started their MEAP (Manning Early Access Program) for the book I am working on.  What this means for you is <a href="http://manning.com/trebitowski/">FREE DOWNLOADS</a>.  There is currently only one chapter available, but there will be more as the book progresses.</p>
<p>The chapter currently available is about audio recording and playback.  It goes into detail about the AVAudio frameworks as well as the MPMediaPlayer.</p>
<p>So be sure to <a href="http://manning.com/trebitowski/">check it out</a> and feedback on the chapter is GREATLY appreciated.</p>
<p><a href="http://manning.com/trebitowski/">Link to MEAP</a></p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/11/11/iphone-in-action-book-free-chapter-downloads/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>iPhone Coding Tutorial &#8211; Inserting A UITextField In A UIAlertView</title>
		<link>http://icodeblog.com/2009/11/09/iphone-coding-tutorial-inserting-a-uitextfield-in-a-uialertview/</link>
		<comments>http://icodeblog.com/2009/11/09/iphone-coding-tutorial-inserting-a-uitextfield-in-a-uialertview/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 02:46:18 +0000</pubDate>
		<dc:creator>AppStoreMod</dc:creator>
				<category><![CDATA[iPhone Game Programming]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1463</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/11/09/iphone-coding-tutorial-inserting-a-uitextfield-in-a-uialertview/"><img align="left" hspace="5" width="150" src="http://icodeblog.com/wp-content/uploads/2009/11/Screen-shot-2009-11-09-at-8.12.11-AM-copy.png" class="alignleft wp-post-image tfe" alt="Screen shot 2009-11-09 at 8.12.11 AM copy" title="" /></a>This will be a simple tutorial showing you how to put a UITextField in a UIAlertView. This is simple and just a couple lines if code. You will learn CGAffineTransform and coding UITextField programmatically.
Heres a screenshots of what we should get.

So lets go ahead and get started&#8230;
1. Create A New View Based Application
You can name [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-1473" src="http://icodeblog.com/wp-content/uploads/2009/11/Screen-shot-2009-11-09-at-8.12.11-AM-copy.png" alt="Screen shot 2009-11-09 at 8.12.11 AM copy" width="200" height="96" />This will be a simple tutorial showing you how to put a UITextField in a UIAlertView. This is simple and just a couple lines if code. You will learn CGAffineTransform and coding UITextField programmatically.<span id="more-1463"></span></p>
<p>Heres a screenshots of what we should get.</p>
<p><img class="size-full wp-image-1472 alignnone" src="http://icodeblog.com/wp-content/uploads/2009/11/Screen-shot-2009-11-09-at-8.12.11-AM.png" alt="Screen shot 2009-11-09 at 8.12.11 AM" width="260" height="388" /></p>
<p>So lets go ahead and get started&#8230;</p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">1. Create A New View Based Application</span><br />
<span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px"><span style="color: #000000;font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;letter-spacing: normal;line-height: 19px;font-size: 13px">You can name it whatever you want, I am gonna name it TextFieldInAlert.</span></span><br />
<span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px"> </span></p>
<p><span style="font-family: helvetica, arial, sans-serif;line-height: 40px;font-size: 34px;color: #225e8a;letter-spacing: -2px">2. Implementing The Code</span><br />
Jump in the viewcontroller.m or if you called it TextFieldInAlert then TextFieldInAlert.m Now find the -(void)viewDidLoad method. Uncomment it and put this code in there.</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">- (<span style="color: #c800a7">void</span>)viewDidLoad {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000"> [</span><span style="color: #c800a7">super</span><span style="color: #000000"> </span>viewDidLoad<span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> *alert = [[</span><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> </span>alloc<span style="color: #000000">] </span>initWithTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Enter Name Here&#8221;</span><span style="color: #000000"> </span>message<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;this gets covered!&#8221;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #dd0005"> </span>delegate<span style="color: #000000">:</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>cancelButtonTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Dismiss&#8221;</span><span style="color: #000000"> </span>otherButtonTitles<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;OK!&#8221;</span><span style="color: #000000">, </span><span style="color: #c800a7">nil</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span style="color: #7b1caf">UITextField</span> *myTextField = [[<span style="color: #7b1caf">UITextField</span> <span style="color: #470086">alloc</span>] <span style="color: #470086">initWithFrame</span>:<span style="color: #470086">CGRectMake</span>(<span style="color: #4100e0">12</span>, <span style="color: #4100e0">45</span>, <span style="color: #4100e0">260</span>, <span style="color: #4100e0">25</span>)];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000">[myTextField </span>setBackgroundColor<span style="color: #000000">:[</span><span style="color: #7b1caf">UIColor</span><span style="color: #000000"> </span>whiteColor<span style="color: #000000">]];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">addSubview</span>:myTextField];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">show</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">release</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[myTextField <span style="color: #470086">release</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">}</p>
</blockquote>
<p>So we are basically calling a UIAlertView and then we are adding the UITextField programmatically. You might have noticed in the message part of the UIAlertView we put &#8220;this gets covered!&#8221;, if we didn&#8217;t put that sentence then the alerts buttons would go up more and the UITextField will be messed. You can try taking that line out and see what happens. Now Build and Run the app. Now you got the UITextField to be inside the UIAlertView. Now try tapping the UITextField. Uh oh, why is the Keyboard covering the UIAlertView? Well there is just a simple fix to this. We just add two more lines of code and it will fix that. Add this to your code</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #7b1caf">CGAffineTransform</span><span style="color: #000000"> myTransform = </span>CGAffineTransformMakeTranslation<span style="color: #000000">(</span><span style="color: #4100e0">0</span><span style="color: #000000">, </span><span style="color: #4100e0">60</span><span style="color: #000000">);</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">setTransform</span>:myTransform];</p>
</blockquote>
<p>So now your full code should be looking like this.</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> *alert = [[</span><span style="color: #7b1caf">UIAlertView</span><span style="color: #000000"> </span>alloc<span style="color: #000000">] </span>initWithTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Enter Name Here&#8221;</span><span style="color: #000000"> </span>message<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;this gets covered!&#8221;</span><span style="color: #000000"> </span>delegate<span style="color: #000000">:</span><span style="color: #c800a7">self</span><span style="color: #000000"> </span>cancelButtonTitle<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;Dismiss&#8221;</span><span style="color: #000000"> </span>otherButtonTitles<span style="color: #000000">:</span><span style="color: #dd0005">@&#8221;OK!&#8221;</span><span style="color: #000000">, </span><span style="color: #c800a7">nil</span><span style="color: #000000">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo"><span style="color: #7b1caf">UITextField</span> *myTextField = [[<span style="color: #7b1caf">UITextField</span> <span style="color: #470086">alloc</span>] <span style="color: #470086">initWithFrame</span>:<span style="color: #470086">CGRectMake</span>(<span style="color: #4100e0">12</span>, <span style="color: #4100e0">45</span>, <span style="color: #4100e0">260</span>, <span style="color: #4100e0">25</span>)];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #7b1caf">CGAffineTransform</span><span style="color: #000000"> myTransform = </span>CGAffineTransformMakeTranslation<span style="color: #000000">(</span><span style="color: #4100e0">0</span><span style="color: #000000">, </span><span style="color: #4100e0">60</span><span style="color: #000000">);</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">setTransform</span>:myTransform];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo;color: #470086"><span style="color: #000000">[myTextField </span>setBackgroundColor<span style="color: #000000">:[</span><span style="color: #7b1caf">UIColor</span><span style="color: #000000"> </span>whiteColor<span style="color: #000000">]];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">addSubview</span>:myTextField];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">show</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px;font: 11.0px Menlo">[alert <span style="color: #470086">release</span>];</p>
<p style="font: normal normal normal 11px/normal Menlo;margin: 0px">[myTextField <span style="color: #470086">release</span>];</p>
</blockquote>
<p>Now if you Build and Run, you will notice the UITextField is a little higher and when you tap the UITextField the Keyboard doesn&#8217;t cover it up anymore. That is what the CGAffineTransform was for. So that is basically it! There is a video tutorial also available and if you like video tutorial more then written ones you can check it out out by clicking <a href="http://www.youtube.com/watch?v=1BvuD6MAPmU">HERE</a>. You can download the source code below. Happy iCoding!</p>
<p><a href="http://xcode.appstoremod.com/TextFieldInAlert.zip">iPhone Tutorial &#8211; UITextField In A UIAlertView</a></p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/11/09/iphone-coding-tutorial-inserting-a-uitextfield-in-a-uialertview/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>iPhone Tech Talk World Tour: San Jose</title>
		<link>http://icodeblog.com/2009/11/05/iphone-tech-talk-world-tour-san-jose/</link>
		<comments>http://icodeblog.com/2009/11/05/iphone-tech-talk-world-tour-san-jose/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 17:33:49 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1453</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/11/05/iphone-tech-talk-world-tour-san-jose/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/11/photo-4-150x150.jpg" class="alignleft wp-post-image tfe" alt="photo 4" title="photo 4" /></a>
Last week I went out to San Jose, CA to go to Apple&#8217;s iPhone Tech Talk World Tour!

Apple once a year holds 9 single day &#8220;Tech Talks&#8221; across the world. This year only 3 were in the US and I was lucky enough to get a spot at the San Jose meetup. The conference was [...]]]></description>
			<content:encoded><![CDATA[<div class="preface">
<p>Last week I went out to San Jose, CA to go to Apple&#8217;s iPhone Tech Talk World Tour!</p></div>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/11/photo-4.jpg"><img class="aligncenter size-full wp-image-1460" title="photo 4" src="http://icodeblog.com/wp-content/uploads/2009/11/photo-4.jpg" alt="photo 4" width="300" height="400" /></a><br />
Apple once a year holds 9 single day &#8220;Tech Talks&#8221; across the world. This year only 3 were in the US and I was lucky enough to get a spot at the San Jose meetup. The conference was focused on getting developers to use best practices in all regions of their applications. Apple&#8217;s stance was even if the app is small, it might as well be designed as well as possible.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/11/photo-3.jpg"><img class="aligncenter size-full wp-image-1459" title="photo 3" src="http://icodeblog.com/wp-content/uploads/2009/11/photo-3.jpg" alt="photo 3" width="400" height="300" /></a></p>
<p>The day started with a nice overview of the iPhone platform. They sell tons of these things and people seem to love the App store. No real news there. Nice overview of the creative apps in the store. Certainly got everyone&#8217;s brains working for an exciting day.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/11/photo-2.jpg"><img class="aligncenter size-full wp-image-1458" title="photo 2" src="http://icodeblog.com/wp-content/uploads/2009/11/photo-2.jpg" alt="photo 2" width="400" height="300" /></a></p>
<p>After looking over all the sessions I decided to spend my whole day in Room A which seemed to focus on the performance, threading and data management. The main tech point to take away from the conference was how threading is done on the iPhone. Apple&#8217;s goal is to abstract away the complexities of classical threading. I went to an hour session on it and the only times I heard the words semaphore or lock was the speaker saying that they didn&#8217;t exist anymore.</p>
<p>The iPhone has may build in calls which are blocking calls. This means that when performed on the main thread functionality will halt until they are done. A very commonly used blocking call is initWithContentsOfURL:. This method is used commonly for XML parsing and grabbing images from the internet. Apple has created a solution for this that essentially automizes your thread management with a single line of code. Lets say for example I am creating an app that on launch parses an XML source. If I have a containing method called parseXML() that does all the parsing I can call this method on a managed thread simply by using.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSOperationQueue</span> <span style="color: #002200;">*</span>queue <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSOperationQueue</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSInvocationOperation</span> <span style="color: #002200;">*</span>op <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSInvocationOperation</span> alloc<span style="color: #002200;">&#93;</span> initWithTarget<span style="color: #002200;">:</span>self selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>parseXML<span style="color: #002200;">&#41;</span> object<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>queue addOperation<span style="color: #002200;">:</span>op<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>op release<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>That&#8217;s it. Apple has made a general class called NSOperation that gives users the power to create their own automated threading classes. In this case I am using the built in NSIvocationoperation object that takes in a method and runs it on a secondary thread. Throw the operation into an operation queue and you are done. Very powerful stuff.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/11/photo-1.jpg"><img class="aligncenter size-full wp-image-1461" title="photo-1" src="http://icodeblog.com/wp-content/uploads/2009/11/photo-1.jpg" alt="photo-1" width="400" height="300" /></a></p>
<p>Aside from the fun tech stuff it was a great opportunity to meet people in the developer community and share ideas.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/11/05/iphone-tech-talk-world-tour-san-jose/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>iPhone Coding Tutorial &#8211; Creating an Online Leaderboard For Your Games</title>
		<link>http://icodeblog.com/2009/10/29/iphone-coding-tutorial-creating-an-online-leaderboard-for-your-games/</link>
		<comments>http://icodeblog.com/2009/10/29/iphone-coding-tutorial-creating-an-online-leaderboard-for-your-games/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 16:14:50 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[iPhone Game Programming]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iPhone Coding]]></category>
		<category><![CDATA[iphone game]]></category>
		<category><![CDATA[leaderboard]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1426</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/10/29/iphone-coding-tutorial-creating-an-online-leaderboard-for-your-games/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_011-150x150.png" class="alignleft wp-post-image tfe" alt="screenshot_01" title="screenshot_01" /></a>As you may have seen, there are quite a few services out there offering free leaderboards.  These are great and all, but sometimes you want to have complete control over your data.  I have put together a complete tutorial detailing step by step how you can create your own online leaderboard.  This will also give you a very simple introduction to interfacing with web services.]]></description>
			<content:encoded><![CDATA[<p>As you may have seen, there are quite a few services out there offering free leaderboards.  These are great and all, but sometimes you want to have complete control over your data.  I have put together a complete tutorial detailing step by step how you can create your own online leaderboard for use in your iPhone games.  For those of you who don&#8217;t know, a leaderboard is essentially a high scores list.  This tutorial will also give you a very simple introduction to interfacing with web services.</p>
<p>The first part of this tutorial will discuss how to build the server.  We will be doing this using PHP and MYSQL.  I will also assume you have some working knowledge of PHP and MYSQL (if not, use the Google machine to get up to speed).</p>
<p>Since this tutorial is so long, I have decided to split it up into pages.  You will notice the page number at the bottom.  Please use them to navigate between parts of this post.  I feel that I have to make this explicit as I will undoubtably get some dude in the comments saying &#8220;Where is the rest of the tutorial&#8221;.  </p>
<p>Skill level: <font color="red">Advanced</font></p>
<h2>Creating The Database</h2>
<p>When creating a leaderboard, you will need some way of storing the data.  We will be using MYSQL for our storage.  You can also be lame and simply use flat files.  This would add quite a bit of code in the long run as you would have to write all of the sorting and pagination functionality yourself. Don&#8217;t do it.</p>
<p>One thing to note about my php server files.  I know they could be cleaned up a little and optimized (you could create a config.php that contains all the db interface code), but the goal of this tutorial is not to show you how to code killer PHP.  It&#8217;s to show you how to create code that you can connect your iPhone apps to.</p>
<p>I like to create one file that does a complete flash of the database.  That way, when I&#8217;m testing or switch from staging to production, it is a very simple process.  So, with that being said, here is my code for create_db.php.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
        <span style="color: #666666; font-style: italic;">// create_db.php</span>
	<span style="color: #009933; font-style: italic;">/** MySQL database name */</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_NAME'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009933; font-style: italic;">/** MySQL database username */</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_USER'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009933; font-style: italic;">/** MySQL database password */</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_PASSWORD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009933; font-style: italic;">/** MySQL hostname */</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB_HOST'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_ENV</span><span style="color: #009900;">&#123;</span>DATABASE_SERVER<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;highscores&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Initialization</span>
	<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span>DB_HOST<span style="color: #339933;">,</span>DB_USER<span style="color: #339933;">,</span>DB_PASSWORD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span>DB_NAME<span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Error checking</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Could not connect '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Drop existing table if exists</span>
	<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DROP TABLE <span style="color: #006699; font-weight: bold;">$table</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$retval</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;CREATE TABLE <span style="color: #006699; font-weight: bold;">$table</span>(
		id INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
		udid VARCHAR(45),
		name VARCHAR(25),
		score FLOAT(10,2),
		date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
	)&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$retval</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Database created...&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Could not create database &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>I&#8217;m not going to go into too much detail about this code, however I will give a high level description of what&#8217;s going on.  One thing to note about this code is it assumes you already have the database created.</p>
<p>First, we are defining variables that contain our database information.  Make sure you replace my empty strings with your database info. After we connect to the database, we drop the table if it already exists.  This is useful if you want to wipe out your test data.  Finally, we create the scores table.  Navigate to this file in your browser to run it and create the scores table.  Pretty easy right?</p>
<p><font color="red">You will want to make sure to remove this file from your server after running it to avoid people resetting your database.</font></p>
<p>Now that our database table has been created, it&#8217;s time to implement the web service code to publish new scores to our leaderboard.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/10/29/iphone-coding-tutorial-creating-an-online-leaderboard-for-your-games/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Floodgates opened for iPhone development</title>
		<link>http://icodeblog.com/2009/10/12/floodgates-opened-for-iphone-development/</link>
		<comments>http://icodeblog.com/2009/10/12/floodgates-opened-for-iphone-development/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 18:56:30 +0000</pubDate>
		<dc:creator>rick</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone Articles]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1418</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/10/12/floodgates-opened-for-iphone-development/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>For as active as iPhone application development community is, achieving success in iTunes has been an elusive affair for those who participate in this vertical.  The two main obstacles presented to anyone who wants to create an iPhone applications are: one, finding resources/developers with the right skill set; and two, marketing the application after the application has been submitted.  The bad news is Apple keeps iTunes a black box.  Unless your application has been reviewed or mentioned on review sites or blogs, no one will be able to find your application outside of iTunes.  This makes marketing your application relatively difficult.  Here's the good news: the cost to build an iPhone application should come down substantially as it no longer requires a developer with an exclusive knowledge to a specific technology to build an application for iPhone.]]></description>
			<content:encoded><![CDATA[<p>For as active as iPhone application development community is, achieving success in iTunes has been an elusive affair for those who participate in this vertical.  The two main obstacles presented to anyone who wants to create an iPhone applications are: one, finding resources/developers with the right skill set; and two, marketing the application after the application has been submitted.  The bad news is Apple keeps iTunes a black box.  Unless your application has been reviewed or mentioned on review sites or blogs, no one will be able to find your application outside of iTunes.  This makes marketing your application relatively difficult.  Here&#8217;s the good news: the cost to build an iPhone application should come down substantially as it no longer requires a developer with an exclusive knowledge to a specific technology to build an application for iPhone.</p>
<p>When Apple first announced to openly accept applications from developers, the prerequisite for the developer is a somewhat extensive knowledge in a language called &#8220;Objective-C.&#8221;  For a short while, it would seem as though the developers who could produce Objective-C codes were superstars that also came with a superstar price tag.  Such stardom, however, did not last.  When <a href="http://phonegap.com">PhoneGap</a> was introduced as an open source development tool for iPhone via JavaScript, the web development community devoured it like salmon to a hungry bear.  Shortly after PhoneGap&#8217;s success, <a href="http://www.mono-project.com">Mono framework</a> was released in the commercial sector that provided the necessary development tools to the vast number of C# developers across multiple platforms.  And to unhinge the final bar from the floodgates, Adobe has <a href="http://www.informationweek.com/news/internet/webdev/showArticle.jhtml?articleID=220301118">just announced</a> that the next release of Flash is capable of compiling a flash project directly into native iPhone application.  Simply put, a project can go from design to finish without even being touched by a developer.</p>
<p>The implication for this phenomenon is a curious one: how will Apple respond to the rush of new applications when the floodgates are finally open?  Will Apple still be able to keep its manual review process intact?  When the market is saturated with developers and applications, will Apple be able to to maintain iTunes exclusive distribution channel and continue to motivate merchants to participate?</p>
<p>How all of this will affect Apple or iPhone developers is yet to be seen.  However, one thing that seems to be true is that when given enough demands, people will find ways to liberate a technology regardless of how businesses are structured around it.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/10/12/floodgates-opened-for-iphone-development/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Debugging Tutorial &#8211; Automating Your Tests With A UIRecorder Instrument</title>
		<link>http://icodeblog.com/2009/10/06/debugging-tutorial-automating-your-tests-with-a-uirecorder-instrument/</link>
		<comments>http://icodeblog.com/2009/10/06/debugging-tutorial-automating-your-tests-with-a-uirecorder-instrument/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 21:20:00 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iPhone Coding]]></category>
		<category><![CDATA[iphone debugging]]></category>
		<category><![CDATA[uirecorder]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1403</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/10/06/debugging-tutorial-automating-your-tests-with-a-uirecorder-instrument/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_01-150x150.png" class="alignleft wp-post-image tfe" alt="screenshot_01" title="screenshot_01" /></a>If you have ever experienced a bug in your application that took many steps to reproduce, then this tutorial is for you.  By nature, testing and debugging are very tedious processes.  This is especially the case for the iPhone.
Say you have an app that drills down 5-levels deep to some other view.  Now let&#8217;s say [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever experienced a bug in your application that took many steps to reproduce, then this tutorial is for you.  By nature, testing and debugging are very tedious processes.  This is especially the case for the iPhone.</p>
<p>Say you have an app that drills down 5-levels deep to some other view.  Now let&#8217;s say that you have a bug on that view 5 levels deep.  Your normal method of debugging is:</p>
<ul>
<li>Run the app</li>
<li>Tap view 1</li>
<li>Tap view 2</li>
<li>Tap view 3</li>
<li>Tap view 4</li>
<li>Tap view 5</li>
<li>(Crash)</li>
<li>Change some code</li>
<li>Repeat</li>
</ul>
<p>As you can see (and I&#8217;m sure have noticed), this sucks.  Well, <a href="http://twitter.com/kendalldevdiary">Kendall Gelner</a> gave a killer talk at <a href="http://www.360idev.com/">360iDev</a> (which I recently attended) on various debugging tips using Instruments and XCode.  One of the most useful techniques (to me) was how to automate your testing.  Let me show you what I mean.</p>
<p>1. Open up the app you wish to test/debug</p>
<p>2. Launch it in the simulator</p>
<p>3. Open <strong>Instruments</strong> &#8211; This is located in /Developer/Applications/Instruments (just do a spotlight search for it)</p>
<p><strong><a href="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_01.png"><img class="alignnone size-medium wp-image-1404" title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_01-300x229.png" alt="screenshot_01" width="300" height="229" /></a></strong></p>
<p>4. Select <strong>UIRecorder</strong> and click <strong>Choose </strong>- You should now see a window like this</p>
<p><strong><a href="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_02.png"><img class="alignnone size-medium wp-image-1406" title="screenshot_02" src="http://icodeblog.com/wp-content/uploads/2009/10/screenshot_02-300x211.png" alt="screenshot_02" width="300" height="211" /></a></strong></p>
<p>5. Now, we need to attach this tool to the iPhone Simulator process.  Click the drop-down above <strong>Default Target</strong> -&gt; <strong>Attach to Process </strong>-&gt; <strong>iPhone Simulator</strong>.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/10/ss_03.png"><img class="alignnone size-medium wp-image-1409" title="ss_03" src="http://icodeblog.com/wp-content/uploads/2009/10/ss_03-300x136.png" alt="ss_03" width="300" height="136" /></a></p>
<p>6. Now click <strong>Drive &amp; Record</strong> and do all of the steps in the simulator to test your app.  At this point, the UI Recorder is recording your every move.  When you have finished press the <strong>Stop </strong>button. <span style="color: #ff0000;">Note</span>: After you have recorded your actions, don&#8217;t move the simulator as it will mess up the entire process.</p>
<p>7. Modify your code&#8230;</p>
<p>8. Press the <strong>Drive &amp; Record </strong>button and watch the magic happen.  The test is automatically done for you.  You should see your mouse move over to the simulator and the system mimicking every action that you did before.</p>
<p>That&#8217;s it! I know this isn&#8217;t a super long tutorial (or even a coding tutorial), but the UI Recorder has sped my test time up tremendously.  Give it a shot and let me know what you think.  Here is a short video of me going through all of the steps.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=6934052&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=6934052&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/6934052">iCodeBlog &#8211; Debugging Tutorial &#8211; Automating Your Tests With A UIRecorder Instrument</a> from <a href="http://vimeo.com/user2413855">Brandon Trebitowski</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Happy iCoding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/10/06/debugging-tutorial-automating-your-tests-with-a-uirecorder-instrument/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>360iDev Conference Day 1</title>
		<link>http://icodeblog.com/2009/09/27/360idev-conference-day-1/</link>
		<comments>http://icodeblog.com/2009/09/27/360idev-conference-day-1/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 03:05:12 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[360idev]]></category>
		<category><![CDATA[iphone dev]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1396</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/09/27/360idev-conference-day-1/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/09/360iDev_Logo_date-150x150.png" class="alignleft wp-post-image tfe" alt="360iDev_Logo_date" title="360iDev_Logo_date" /></a>
Today was the beginning of the 360iDev conference in Denver Colorado.  So far, I must say I am very impressed.  There have been some great speakers and some very smart dudes in attendance.  In case you are unfamiliar with 360iDev, here is a bit about it (from their website).
360&#124;iDev is the premiere iPhone, iPod Touch [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.360idev.com/"><img class="size-full wp-image-1398 aligncenter" title="360iDev_Logo_date" src="http://icodeblog.com/wp-content/uploads/2009/09/360iDev_Logo_date.png" alt="360iDev_Logo_date" width="276" height="179" /></a></p>
<p>Today was the beginning of the <a href="http://www.360idev.com/">360iDev conference</a> in Denver Colorado.  So far, I must say I am very impressed.  There have been some great speakers and some very smart dudes in attendance.  In case you are unfamiliar with 360iDev, here is a bit about it (from their <a href="http://www.360idev.com/">website</a>).</p>
<blockquote><p>360|iDev is the premiere iPhone, iPod Touch developer conference in the world. We bring together the best speakers and sponsors in the industry under one roof!</p></blockquote>
<p>The conference is a 3 day (technically 4 day) event held at the Curtis hotel.  Here is some info about the sessions I attended today:</p>
<h2>1. Advanced Debugging &#8211; Kendall Helmstetter Gelner</h2>
<p>I know, sounds boring right? It was actually very informative.  Proper debugging is something that is often overlooked in software development, especially iPhone development.  With everyone trying to push out apps so fast, they often miss many simple memory issues that are detrimental to their apps.</p>
<p>This talk discussed many of the tools available to help you debug including:</p>
<ul>
<li>Instruments &#8211; From here you have a huge range of tools available to you.  You can even create your own custom tools in order to help you as much as possible.  Here are some of the instruments we used.
<ul>
<li>UIRecorder &#8211; This is crazy cool.  It allows you to record your actions in the iPhone simulator.  So if you can reproduce a bug, but it takes many steps (tapping table cells, typing, etc&#8230;), you can record the steps, and the next run will do exactly what you just did.</li>
<li>Object Allocations &#8211; Shows you information about every object in memory.  This is useful to determine which objects are taking up memory and slowing down your apps</li>
<li>DTrace Instrument &#8211; This allows you to define your own custom instrument. We used it to notify us what object were calling specific methods in our code.</li>
</ul>
</li>
<li>GDB &#8211; This seems scary to most, but can prove to be quite useful.  We learned how to set breakpoints, dive into the stack, and even &#8220;go back in time&#8221;</li>
<li>NSZombieEnabled &#8211; Cool name ehh? This allows you to see objects that get deallocated but still get referenced in memory.</li>
</ul>
<p><a href="http://kroucis.wordpress.com/">You can check out Kendall&#8217;s blog here.</a></p>
<h2>2. Code Injection &#8211; Saurik</h2>
<p>For those of you unfamiliar with the name <a href="http://www.saurik.com/">Saurik</a>, he is the creator of <a href="http://cydia.saurik.com/">Cydia</a>. Cydia is like the App Store for jailbroken iPhones.  This guy really knows his stuff.</p>
<p>He started off by giving us a &#8220;state of the union&#8221; on the jailbroken world and then began to go into detail about how he managed to hack the iPhone.  It starts off relatively simple and then gets very complex, very quickly.</p>
<p>This talk was a little over my head as much of it was done in assembly, but it was still very informative. The coolest part was his code demo.  He spent about 2 hours or so and hacked the Google Maps app on the 3GS.  He said that he didn&#8217;t like that the map rotated when you rotate the phone and only wanted to the direction indicator to rotate.  So, he did just this.</p>
<p>Saurik hacked away, explaining as he went and didn&#8217;t refer to the Apple documentation once.  You would have thought he wrote the SDK as he had in depth knowlege of all of the underlying files and private frameworks. Most of his coding was in C and assembly.  BTW &#8211; he was coding on a Windowz machine.  This dude was awesome, makes me want to jailbreak my phone.</p>
<p>As for tonight, we had a part hosted by <a href="http://www.medialets.com/">MediaLets</a>.  Food, beer, and of course Rockband.  Here&#8217;s a pic from the party:</p>
<p><img class="alignnone size-full wp-image-1397" title="32656821" src="http://icodeblog.com/wp-content/uploads/2009/09/32656821.jpg" alt="32656821" width="600" height="450" /></p>
<p>I have 3 more days of 360iDev and am very stoked for the next classes.  There will be everything from push notifications to game dev.  I will be sure to post info about each session along the way.  Also, I will have some killer tutorial ideas by the end.  For those of you who didn&#8217;t make it this year, I would highly recommend it (based on what I have seen so far). Another post coming tomorrow.</p>
<p>To keep up with what&#8217;s going on at the conference in real time, just follow the search term <a href="http://twitter.com/#search?q=360idev">360idev</a> on twitter. (<a href="http://twitter.com/#search?q=360idev">http://twitter.com/#search?q=360idev</a>)</p>
<p>Happy iCoding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/09/27/360idev-conference-day-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Code Snippet &#8211; Quickly Find The Documents Directory</title>
		<link>http://icodeblog.com/2009/09/09/code-snippet-quickly-find-the-documents-directory/</link>
		<comments>http://icodeblog.com/2009/09/09/code-snippet-quickly-find-the-documents-directory/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 14:54:18 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone Coding]]></category>
		<category><![CDATA[iphone dev]]></category>
		<category><![CDATA[iphone documents]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[save files]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1295</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/09/09/code-snippet-quickly-find-the-documents-directory/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>As many of you may have seen by now, there are quite a few ways to find the documents directory on the iPhone.  For those of you who don&#8217;t know, the documents directory of an app is the location where you should save your application data.  While finding the documents directory is a trivial task, [...]]]></description>
			<content:encoded><![CDATA[<p>As many of you may have seen by now, there are quite a few ways to find the documents directory on the iPhone.  For those of you who don&#8217;t know, the documents directory of an app is the location where you should save your application data.  While finding the documents directory is a trivial task, it is very important when coding most applications.  Apple has provided quite a few ways for resolving the path to this directory.</p>
<p>If you read through some of Apple&#8217;s sample code, you will see their code to do this is generally 3 or 4 lines long.  This seems like a lot of code to perform such a simple task.  Here is a nice one-liner for you to use in your applications.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> docs <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSHomeDirectory<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>
						   stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Documents&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>It&#8217;s clean and concise.  Happy iCoding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/09/09/code-snippet-quickly-find-the-documents-directory/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Objective-C Tutorial: NSArray</title>
		<link>http://icodeblog.com/2009/08/26/objective-c-tutorial-nsarray/</link>
		<comments>http://icodeblog.com/2009/08/26/objective-c-tutorial-nsarray/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 19:04:46 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[iPhone Articles]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iPhone Coding]]></category>
		<category><![CDATA[iphone dev]]></category>
		<category><![CDATA[nsarray]]></category>
		<category><![CDATA[NSMutableArray]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1268</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/08/26/objective-c-tutorial-nsarray/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>The NSArray is a huge workhorse that we use quite frequently without even thinking about it.  The NSArray class isn't just your ordinary array.  Not only does it provide random access, but it also dynamically re-sizes when you add new objects to it.  While I won't go over every method in NSArray (there are quite a few), I will discuss some of the more important ones that are most commonly used.  Let's take a closer look at this class.]]></description>
			<content:encoded><![CDATA[<p>Here at iCodeblog, we have been showing you guys how to create many different types of applications from the ground up.  Well, today I decided to do something different and get down to some of the nitty gritty of a structure we rely heavily on in objective-C.</p>
<p>The NSArray is a huge workhorse that we use quite frequently without even thinking about it.  The NSArray class isn&#8217;t just your ordinary array.  Not only does it provide random access, but it also dynamically re-sizes when you add new objects to it and has many methods to make our lives easier.  While I won&#8217;t go over every method in NSArray (there are quite a few), I will discuss some of the more important ones that are most commonly used.  Let&#8217;s take a closer look at this class.</p>
<h2>Factory Methods</h2>
<p>Factory methods are <a href="http://en.wikipedia.org/wiki/Static_method#Static_methods">static methods</a> that build new instances of NSArrays from given parameters and return them.  The table below details on all of the factory methods for the NSArray class.</p>
<table style="border: 1px solid #000000; width: 100%;" border="0">
<tbody>
<tr>
<td><strong>+ (id)array</strong></td>
<td>Creates and returns an empty array</td>
</tr>
<tr>
<td><strong>+ (id)arrayWithArray:(NSArray *)anArray</strong></td>
<td>Creates and returns an array containing the objects in another given array.</td>
</tr>
<tr>
<td><strong>+ (id)arrayWithContentsOfFile:(NSString *)aPath</strong></td>
<td>Creates and returns an array containing the contents of the file specified by a given path. <span style="color: red;">*</span> The file must be of type .plist for this method to work</td>
</tr>
<tr>
<td><strong>+ (id)arrayWithContentsOfURL:(NSURL *)aURL</strong></td>
<td>Similar to arrayWithContentsOfFile except it will load the .plist remotely from a given website.  This would be a very simple way to get data from a web service.</td>
</tr>
<tr>
<td><strong>+ (id)arrayWithObject:(id)anObject</strong></td>
<td>Creates and returns an array containing a given object.  This will just be a 1 element array</td>
</tr>
<tr>
<td><strong>+ (id)arrayWithObjects:(id)firstObj, &#8230;</strong></td>
<td>This method is used when you have multiple objects on hand and want easily insert them into an array.  Make sure the last element you add is nil or this method won&#8217;t work.</td>
</tr>
<tr>
<td><strong>+ (id)arrayWithObjects:(const id *)objects count:(NSUInteger)count</strong></td>
<td>Creates and returns an array that includes a given number of objects from a given C array.</td>
</tr>
</tbody>
</table>
<p>Here is some example usage of building NSArrays with these factory methods&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// I am using strings, but you can add just about any object to an NSArray</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">// Creates an NSArray with one object</span>
<span style="color: #400080;">NSArray</span>  <span style="color: #002200;">*</span> myArray <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObject<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;foo&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Creates an NSArray with multiple objects. Don't forget to add nil as the last object</span>
<span style="color: #400080;">NSArray</span>  <span style="color: #002200;">*</span> myArray2 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;foo&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bar&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;baz&quot;</span>,<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// Creates an NSArray from another NSArray</span>
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span> myArray3 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithArray<span style="color: #002200;">:</span>myArray2<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #11740a; font-style: italic;">// This will create an NSArray from data on iCodeBlog.  Go ahead and try it out, this file exists on our servers and contains valid data.</span>
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span> myArray4 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithContentsOfURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://icodeblog.com/wp-content/uploads/2009/08/foo.plist&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>You can also choose not to use factory methods and just use the normal NSArray initializers.  They are pretty much the same as the factory methods only you do the allocation yourself. An example of this might be:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span> foo <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;foo&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bar&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;baz&quot;</span>,<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<h2>Accessing The NSArray</h2>
<p>Apple has provided us with many great methods for getting data out of an NSArray as well as information about it.  Here is a table of methods and their descriptions.</p>
<table style="border: 1px solid #000000; width: 100%;" border="0">
<tbody>
<tr>
<td>- (BOOL)containsObject:(id)anObject</td>
<td>Returns true if a given object is found in the array, false otherwise</td>
</tr>
<tr>
<td>- (NSUInteger)count</td>
<td>Returns the size of the array</td>
</tr>
<tr>
<td>- (id)lastObject</td>
<td>Returns the last object in the array (the one with the highest index)</td>
</tr>
<tr>
<td>- (id)objectAtIndex:(NSUInteger)index</td>
<td>Gives you random access to the array. Returns the object at a given index.</td>
</tr>
</tbody>
</table>
<p>These are just a few of the accessor methods of NSArray and most likely the only ones you will need to use.</p>
<h2>Searching The Array</h2>
<p>If you are looking for the index of an object in an array, there is really only one method you need to use.  That method is indexOfObject: . An example of usage might be:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> f <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;foo&quot;</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> b <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bar&quot;</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> z <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;baz&quot;</span>;
<span style="color: #400080;">NSArray</span>  <span style="color: #002200;">*</span> myArray2 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span>f,b,z,<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
NSInteger idx <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>myArray2 indexOfObject<span style="color: #002200;">:</span>b<span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// This would return 1 (since NSArrays are 0 - indexed)</span></pre></div></div>

<p>This is much cleaner code than looping over the entire array to find an object. It&#8217;s probably more efficient too as Apple is pretty clean in how they code things.</p>
<h2>Sending Message To Objects In The Array</h2>
<p>Ok, so this is pretty cool.  Say you have an array of objects that all need to do something.  For example, an array of bullets, and you want all of the bullets to move forward one pixel. Rather than looping over each bullet object in the bullets array and calling [bullet move], you can do it in one method call on the array.  This method is called &#8211; (void)makeObjectsPerformSelector:(SEL)aSelector and here is an example of usage.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Lets pretend the bullet object has a method called move</span>
<span style="color: #11740a; font-style: italic;">// and there is an array of 50 bullets</span>
&nbsp;
<span style="color: #002200;">&#91;</span>bullets makeObjectsPerformSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>move<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>And that&#8217;s it&#8230; The move method will now be called on every bullet object in the array with this one method call.  Very clean and easy to use.  Now, if the method you want to call takes an argument, there is the &#8211; (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)anObject method.  This will allow you to pass an object to each method being called.</p>
<h2>Sorting Arrays</h2>
<p>Apple has provided us with some very slick ways to sort an NSArray.  I will not go into too much detail here as I have a full tutorial planned dedicated to sorting arrays.  For now, I will just show you how to sort an NSArray of NSStrings.  The method we will be using is sortedArrayUsingSelector.  Here is the example usage.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>sortedArray <span style="color: #002200;">=</span>
    <span style="color: #002200;">&#91;</span>myArray2 sortedArrayUsingSelector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>caseInsensitiveCompare<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #11740a; font-style: italic;">// This will return a sorted array that looks like [@&quot;bar&quot;,@&quot;baz&quot;,@&quot;foo&quot;]</span></pre></div></div>

<p>You can plug in any of the string compare functions there to compare the strings.  If you are sorting an NSArray of custom objects (like users), you can overwrite the compare method for that object and pass compare in for the selector.  Just make sure you remember the : at the end of the method.</p>
<h2>Looping Through Arrays</h2>
<p>So if you are reading this, I assume you have seen a for loop before.  ex: for(int x=0; x &lt; &#8230; This would most likely not be a good way to enumerate an NSArray as Apple has provided a much nice way for doing so.  There are some situations where this method would be preferred (like when u need to calculate the indices or something).  But in most cases, you will want to use the special for loop provided by Apple. If you have ever coded PHP, it is much like the foreach loop.  Here is an example:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span> myStr <span style="color: #a61390;">in</span> myArray2<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
    NSLog<span style="color: #002200;">&#40;</span>myStr<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>This will loop over myArray2 and pring each element in that array.  Very clean and efficient.</p>
<h2>Saving Arrays For Later</h2>
<p>There is an Array of ways to save data on the iPhone (Pun intended).  One way is to simply dump the array to a file.  This will write out the NSArray to a plist file on disk that can be loaded later using the arrayWithContentsOfFile method of NSArray.  That method is rightfully named writeToFile.  The example usage for it is as follows.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSArray</span>  <span style="color: #002200;">*</span> myArray2 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> arrayWithObjects<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;foo&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;bar&quot;</span>,<span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;baz&quot;</span>,<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>myArray2 writeToFile<span style="color: #002200;">:</span>filePath atomically<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>And there you have it! You are probably wondering what the atomically variable means. Me too&#8230; Just kidding.  If YES, the file will be written to a temp location and then renamed to its final destination.  This is put in place to guarantee that the file won&#8217;t be corrupted even if the system crashes (rename will be much faster than write).  Why is this needed you ask?  Consider this scenario.</p>
<blockquote><p>You want to write a huge array to disk to save it for later.  When your app starts it checks the disk to see if this file exists, if it does it loads an NSArray from it.  If it doesn&#8217;t it creates a new NSArray.  Say the last time the app ran, the system crashed while the file was being written.  If atomically was set to NO, the original file would be corrupt and now the application would be loading corrupt data every time it starts from now on (most likely causing a crash).  However, if you set atomically to YES, the temp file would get corrupted and the app would never see it.  That way, the next time the app starts it will create a new fresh NSArray and all will be good.</p></blockquote>
<p>Good rule of thumb, set atomically to YES.</p>
<p>That concludes our tutorial on NSArray.  If you have any questions or comments, feel free to post them in the comments section or <a href="http://twitter.com/brandontreb">write me on twitter.</a></p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/08/26/objective-c-tutorial-nsarray/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Forums Are Back!</title>
		<link>http://icodeblog.com/2009/08/04/forums-are-back/</link>
		<comments>http://icodeblog.com/2009/08/04/forums-are-back/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 17:25:36 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1259</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/08/04/forums-are-back/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/08/users-150x150.png" class="alignleft wp-post-image tfe" alt="users" title="users" /></a>
After the server switch, we seemed to have lost the forums.  They are now back up at http://icodeblog.com/forum .
I will do my best to keep up with them (as I have tended to neglect them in the past).  Just, please don&#8217;t write posts like &#8220;Would you make a tutorial about creating an online craps game [...]]]></description>
			<content:encoded><![CDATA[<p><meta name="verify-v1" content="WsS387xzaENEKDBbfE/4fbhpVwT4NSS8ku//wb30Aa0=" /></p>
<p><img class="alignright size-full wp-image-1260" title="users" src="http://icodeblog.com/wp-content/uploads/2009/08/users.png" alt="users" width="253" height="238" />After the server switch, we seemed to have lost the forums.  They are now back up at <a href="http://icodeblog.com/forum">http://icodeblog.com/forum</a> .</p>
<p>I will do my best to keep up with them (as I have tended to neglect them in the past).  Just, please don&#8217;t write posts like &#8220;Would you make a tutorial about creating an online craps game that allows user chat&#8221;.  I will not write your programs for you.  I guess in some users case <a href="http://icodeblog.com/2009/07/08/look-familiar/">I already have</a>.</p>
<p>So feel free to chat it up in the forums.  If you have suggestions or improvements to them, leave your comments at the bottom of this post.</p>
<p>Happy iCoding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/08/04/forums-are-back/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to deal with iPhone Device Provisioning without Stabbing Your Eyes Out</title>
		<link>http://icodeblog.com/2009/07/31/how-to-deal-with-iphone-device-provisioning-without-stabbing-your-eyes-out/</link>
		<comments>http://icodeblog.com/2009/07/31/how-to-deal-with-iphone-device-provisioning-without-stabbing-your-eyes-out/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 23:51:33 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1235</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/07/31/how-to-deal-with-iphone-device-provisioning-without-stabbing-your-eyes-out/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-15-150x150.png" class="alignleft wp-post-image tfe" alt="Picture 15" title="Picture 15" /></a>Introduction
So for any developer than has joined the iPhone Development program and attempted to throw their app on their phone, the process of provisioning is a familiar and likely painful process. Like many developer you may have several projects going on possibly for several organizations. You can think of provisioning as the paper work your [...]]]></description>
			<content:encoded><![CDATA[<h1><span style="color: #ff6600;">Introduction</span></h1>
<p>So for any developer than has joined the iPhone Development program and attempted to throw their app on their phone, the process of provisioning is a familiar and likely painful process. Like many developer you may have several projects going on possibly for several organizations. You can think of provisioning as the paper work your app needs to fill out in order to &#8220;board&#8221; your phone. The process involves ____ steps:</p>
<ol>
<li>Get an iPhone Developer Account</li>
<li>Create a certificate request</li>
<li>Download your approved certificate</li>
<li>Register your device</li>
<li>Create an App Id for some app (eg. com.exampleComapny.exampleProduct</li>
<li>Create a provisioning profile that says an app with a certain App ID can run on a device with a certain ID</li>
</ol>
<p>While there may be a headache or two in the first several steps, Apple does provide a fairly robust overview of how to accomplish those things. We are going to focus on a developer who has gone through these steps and has a provisioning profile available on their machine. Now you may have multiple provisioning profiles on a single machine, but doing that just involves more work. I use this quick trick to modify projects to my provioioning profile so that I can help  test etc.</p>
<h1><span style="color: #ff6600;">Instructions</span></h1>
<h3><span style="color: #ff6600;">Step 1</span></h3>
<p>Assuming you already have a project created, open up the terminal and navigate into the directory for the project. In my case I have a project called &#8220;MyTesterProject&#8221;.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-15.png"><img class="aligncenter size-full wp-image-1237" title="Picture 15" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-15.png" alt="Picture 15" width="553" height="265" /></a></p>
<h3><span style="color: #ff6600;">Step 2<br />
</span></h3>
<p>Now if we do an ls command we can see that there is a .xcodeproj in this directory. We are going to navigate into that. Although in Finder this may look like a file, it is actually a bundle or folder that has things contained in it. Using the change directory command (cd) we can navigate into the project.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-161.png"><img class="alignleft size-full wp-image-1238" title="Picture 16" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-161.png" alt="Picture 16" width="274" height="137" /></a><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-17.png"><img class="alignright size-full wp-image-1239" title="Picture 17" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-17.png" alt="Picture 17" width="277" height="130" /></a></p>
<h3></h3>
<h3></h3>
<h3></h3>
<h3></h3>
<h3></h3>
<h3><span style="color: #ff6600;">Step 3<br />
</span></h3>
<p>Listing out the directory here we can see that there are several files. The one we are going to focus on is project.pbxproj. This is the file that contains all the configuration settings for this project. What I do here through the terminal is use the command mate to open text mate, however you may use vi or pico or whatever other text editor you like to open the file.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-18.png"><img class="alignleft size-full wp-image-1240" title="Picture 18" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-18.png" alt="Picture 18" width="287" height="107" /></a><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-19.png"><img class="size-large wp-image-1241 alignright" title="Picture 19" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-19-1024x640.png" alt="Picture 19" width="254" height="158" /> </a></p>
<h3><span style="color: #ff6600;">Step 4<br />
</span></h3>
<p>Now you are going to search for whatever developer this project is currently linked to. For this example lets pretend that this project is configured for a provisioning profile for &#8220;Collin Ruffenach&#8221; but we want to change it. Search through this document and find the developers name.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-20.png"><img class="aligncenter size-full wp-image-1242" title="Picture 20" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-20.png" alt="Picture 20" width="582" height="207" /></a></p>
<h3><span style="color: #ff6600;">Step 5<br />
</span></h3>
<p>You will find the name in a section of text that looks similar to this. You need to replace whatever name is there with your name. The other important field begins with &#8220;PROVISIONING_ PROFILE&#8221;.</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-21.png"><img class="aligncenter size-full wp-image-1243" title="Picture 21" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-21.png" alt="Picture 21" width="709" height="238" /></a></p>
<p>The number that you are to replace the provisioning profile number with will be found in xCode. If you go into xCode and into the Window menu, you will see an option for organizer. In organizer you can see all your provisioning profiles. Pick the one you have made for your self and get the Profile Identifier, this is what you will put for the PROVISIONING_PROFILE:</p>
<p style="text-align: center;"><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-25.png"><img class="alignleft size-full wp-image-1247" title="Picture 25" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-25.png" alt="Picture 25" width="181" height="181" /></a><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-26.png"><img class="alignright size-full wp-image-1248" title="Picture 26" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-26.png" alt="Picture 26" width="224" height="160" /></a><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-27.png"><img class="aligncenter size-large wp-image-1249" title="Picture 27" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-27-1024x542.png" alt="Picture 27" width="419" height="220" /></a></p>
<h3><span style="color: #ff6600;">Step 6<br />
</span></h3>
<p>The last thing to do is go into the info.plist file for the project and make sure to change the Bundle Identifier to match the one for the provisioning profile you have. I know at first this seems like a kind of invasive way to do things, but it has really sped up my development and testing time. Hope this tip works for you guys. Thanks for reading and Happy Coding!</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-24.png"><img class="aligncenter size-full wp-image-1246" title="Picture 24" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-24.png" alt="Picture 24" width="557" height="177" /></a></p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/07/31/how-to-deal-with-iphone-device-provisioning-without-stabbing-your-eyes-out/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>iPhone Development: Where is all the $$$</title>
		<link>http://icodeblog.com/2009/07/29/iphone-development-where-is-all-the/</link>
		<comments>http://icodeblog.com/2009/07/29/iphone-development-where-is-all-the/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 01:21:18 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1227</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/07/29/iphone-development-where-is-all-the/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/07/xCodeIcon-150x150.png" class="alignleft wp-post-image tfe" alt="xCodeIcon" title="xCodeIcon" /></a>Hey guys,
So this is the first post we are doing that is more about developers than about developing. The Guardian put up a great article today talking about the app store, developers and what is driving sales. The app store has most certainly solidified itself, at least for the time being, as the most dominant [...]]]></description>
			<content:encoded><![CDATA[<p>Hey guys,<a href="http://icodeblog.com/wp-content/uploads/2009/07/xCodeIcon.png"><img class="alignright size-medium wp-image-1229" title="xCodeIcon" src="http://icodeblog.com/wp-content/uploads/2009/07/xCodeIcon-300x300.png" alt="xCodeIcon" width="300" height="300" /></a></p>
<p>So this is the first post we are doing that is more about developers than about developing. The Guardian put up a great <a title="The App Economy" href="http://www.guardian.co.uk/technology/2009/jul/29/iphone-apps" target="_blank">article</a> today talking about the app store, developers and what is driving sales. The app store has most certainly solidified itself, at least for the time being, as the most dominant mobile application distribution system; but what does the future of the &#8220;App Economy&#8221; look like?</p>
<p>The App Store is really unique in the tech world. There has never been anything that allows consumers and developers to have &#8220;instant&#8221; (sort of for developers) access to such a wide spread digital software storefront. The idea of a piece of software being an impulse buy didn&#8217;t really exist before the App Store, and it is interesting to study the evolution of the apps as well as the evolution of sales. Currently the big winner in app categories is games, little games especially. Got five minutes before that meeting? Pull out <a title="PapiJump in the App Store" href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=285800495&amp;mt=8" target="_blank">PapiJump</a> or maybe <a title="Paper Toss in the App Store" href="http://click.linksynergy.com/fs-bin/stat?id=saW0nB/fQ6o&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252FWebObjects%252FMZStore.woa%252Fwa%252FviewSoftware%253Fid%253D317917431%2526mt%253D8%2526uo%253D6%2526partnerId%253D30" target="_blank">Paper Toss</a>. But these are fleeting. As the App Store gets older, apps will need to evolve in order to keep consumers spending.</p>
<p>A great example of that is a sponsor of our site. <a title="Right Signature in the App Store" href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=306459477&amp;mt=8" target="_blank">Right Signature</a> allows users to send documents to people when a signature is required. This was all done through a web interface until they made their iPhone app. Now lawyers, business owners, anyone can be on the go and sign and return paperwork from anywhere. It is incredible how much time this saves compared to the traditional method of getting people to sign documents. Instead of Print, Mail, Sign, Mail Back; it is Email, Sign.</p>
<p>This is a great example of the internet integration that is going to be vital to most apps coming out. While the iPhone is a pretty incredible device it could never do any high level video processing or other processor intensive task. Thankfully, the internet allows the iPhone to act as a little window into whatever  you would like. You can use your servers to do all the processing and send the result back to the user. Imagine it like sending an SAT test to a tutor online and just getting back the answers. There was a lot of work involved in getting the answers, but in reality all the answers is not very much data.</p>
<p>This is one of the real problems with many new iPhone developers. New developers will get their Objective C down perfectly and suddenly realize that their needs to be a large web based aspect to their app in order to achieve the functionality they are looking for. Most of these &#8220;web based aspects&#8221; will be simple things, like a high score board for instance. However with a well structures web/iphone architecture you could have a large amount of your app be pulled from the web, allowing you to change your app without putting out a new release on the app store. This kind of approach I think should be utilized more for even small things in apps. If the background to a game or the logo of a game changed throughout the course of a year because the images were updated online, this would add some nice personality to some apps that you think have become stagnant. While this does alienate some of the iPod Touch users, a developer could ensure a complete app packadged up requiring no internet yet still incorperate this technique.</p>
<p>Coming up here on iCodeBlog we will be making a full app through several screencasts that we will put in the app store. Right now we are thinking of a small game, but we will make sure to include at lease one web based service within the app. Anyways, make sure to check out the <a title="The App Economy" href="http://www.guardian.co.uk/technology/2009/jul/29/iphone-apps">Guardian Article</a>. Great stuff. Thanks for reading and happy coding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/07/29/iphone-development-where-is-all-the/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Getting Images From The iPhone Photo Library Or Camera Using UIImagePickerController</title>
		<link>http://icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/</link>
		<comments>http://icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 22:23:33 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1200</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/07/photo-21-150x150.jpg" class="alignleft wp-post-image tfe" alt="photo 2" title="photo 2" /></a>This will be a simple tutorial showing you how to access the iPhone&#8217;s photo library as well as the camera.  Since the 3.0 update, the methods for picking photos have been deprecated.  So this will be a 3.0 and above tutorial.
We will be creating an applicaiton that will allow you to pick a [...]]]></description>
			<content:encoded><![CDATA[<p>This will be a simple tutorial showing you how to access the iPhone&#8217;s photo library as well as the camera.  Since the 3.0 update, the methods for picking photos have been <a href="http://en.wikipedia.org/wiki/Deprecation">deprecated</a>.  So this will be a <strong>3.0 and above</strong> tutorial.</p>
<p>We will be creating an applicaiton that will allow you to pick a photo from the library or camera and display it on the screen.  Here is a screenshot of what the app will look like:</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/photo-21.jpg"><img class="alignnone size-full wp-image-1204" title="photo 2" src="http://icodeblog.com/wp-content/uploads/2009/07/photo-21.jpg" alt="photo 2" width="320" height="480" /></a></p>
<p>Let&#8217;s go ahead and get started&#8230;</p>
<h2>1. Create A New View Based Application</h2>
<p>I called mine photoApp (I will be using this name as reference)</p>
<h2>2. Create The IBOutlets and IBAction</h2>
<p>Open <strong>photoAppViewController.h</strong> and add the following code</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import </span>
&nbsp;
<span style="color: #a61390;">@interface</span> PhotoAppViewController <span style="color: #002200;">:</span> UIViewController | UIImagePickerControllerDelegate, UINavigationControllerDelegate | <span style="color: #002200;">&#123;</span>
	UIImageView <span style="color: #002200;">*</span> imageView;
	UIButton <span style="color: #002200;">*</span> choosePhotoBtn;
	UIButton <span style="color: #002200;">*</span> takePhotoBtn;
<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> IBOutlet UIImageView <span style="color: #002200;">*</span> imageView;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> IBOutlet UIButton <span style="color: #002200;">*</span> choosePhotoBtn;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic, retain<span style="color: #002200;">&#41;</span> IBOutlet UIButton <span style="color: #002200;">*</span> takePhotoBtn;
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span> getPhoto<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span> sender;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p><span style="color: #ff0000;">Important</span>: Replace the <strong>|</strong> in the interface declaration with <strong>&lt; </strong>and <strong>&gt;</strong>.  I just used the vertical pipe bc wordpress was replacing it with html encoding.</p>
<p>Notice that we implement the <strong>UIImagePickerControlDelegate</strong> and the <strong>UINavigationControllerDelegate. </strong>These are both needed to properly interface with the image picker.  The rest of this stuff should be pretty strait forward if you have been reading our tutorials.  We set up some outlets to the buttons we are using (this will be to determine which button was pressed).  There is also and IBAction that will get called when the user presses either of the buttons.  This method (getPhoto) will show the ImagePicker.</p>
<h2>3. Create The Interface</h2>
<p>Open up photoAppViewController.xib in Interface builder and follow these steps:</p>
<ol>
<li>Drag a UIImageView on to the main view</li>
<li>Set the <strong>Mode</strong> of the UIImageView to <strong>Aspect Fit</strong> in the Attribute inspector</li>
<li>Drag a UIButton on to the view and title it <strong>Choose Photo</strong></li>
<li>Drag another UIButton on to the view and title it <strong>Take Photo</strong></li>
</ol>
<p>The interface should look something like this:</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/screenshot_013.png"><img class="alignnone size-full wp-image-1209" title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2009/07/screenshot_013.png" alt="screenshot_01" width="320" height="502" /></a></p>
<h2>4. Connect The IBoutlets and IBAction</h2>
<ol>
<li>Connect choosePhotoBtn to the UIButton titled <strong>Choose Photo</strong></li>
<li>Connect takePhotoBtn to the UIButton titled <strong>Take Photo</strong></li>
<li>Connect the imageView to the UIImageView</li>
<li>Connect the <strong>Touch Up Inside</strong> callback on each of the buttons to the <strong>getPhoto </strong>method</li>
</ol>
<p>When you click on <strong>File&#8217;s Owner</strong> the connection inspector should look like this:</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/screenshot_014.png"><img class="alignnone size-full wp-image-1211" title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2009/07/screenshot_014.png" alt="screenshot_01" width="289" height="213" /></a></p>
<p>Close Interface Builder</p>
<h2>5. Implement The getPhoto Method</h2>
<p>Open <strong>PhotoAppViewController.m </strong>and add the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@synthesize</span> imageView,choosePhotoBtn, takePhotoBtn;
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span> getPhoto<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span> sender <span style="color: #002200;">&#123;</span>
	UIImagePickerController <span style="color: #002200;">*</span> picker <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImagePickerController alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
	picker.delegate <span style="color: #002200;">=</span> self;
&nbsp;
	<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span>UIButton <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> sender <span style="color: #002200;">==</span> choosePhotoBtn<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		picker.sourceType <span style="color: #002200;">=</span> UIImagePickerControllerSourceTypeSavedPhotosAlbum;
	<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
		picker.sourceType <span style="color: #002200;">=</span> UIImagePickerControllerSourceTypeCamera;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #002200;">&#91;</span>self presentModalViewController<span style="color: #002200;">:</span>picker animated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Make sure you synthesize your view properties.  Here is what is going on in this method.</p>
<p>We first create a new UIImagePickerController object.  This is a view controller and can be displayed any way you would normally display a view controller (pop on to a navigation view stack, load in a tab view, present as modalviewcontroller).  Next, we set the delegate of the picker to our viewController.  This just means the picker will call a method inside of this class when the user picks a photo.</p>
<p>Next, we determine which button was pressed.  Since both buttons were connected to this method, we can see which one called it by using ==.  Now, here is where Apple has done a great job.  The difference between displaying the camera and photo library comes from setting a single property in the picker.  Looking at the code, it should be pretty obvious which is which.</p>
<p>Finally, we call presentModalViewController with our picker.  This will animate the picker into view from the bottom of the screen to the top.  Depending on the button you press, you should see one of the views below:</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/photo-3.jpg"><img class="size-full wp-image-1202 alignnone" title="photo 3" src="http://icodeblog.com/wp-content/uploads/2009/07/photo-3.jpg" alt="photo 3" width="320" height="480" /></a><a href="http://icodeblog.com/wp-content/uploads/2009/07/photo.jpg"><img class="size-full wp-image-1214 alignnone" title="photo" src="http://icodeblog.com/wp-content/uploads/2009/07/photo.jpg" alt="photo" width="320" height="480" /></a></p>
<h2>6. Displaying The Selected Image</h2>
<p>Once a photo is selected or taken, the ImagePicker will callback to a method in our class called <strong>didFinishPickingMediaWithInfo</strong>.  Add the following code to your <strong>PhotoAppViewController.m<strong> </strong>file. </strong></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: #a61390;">void</span><span style="color: #002200;">&#41;</span>imagePickerController<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIImagePickerController <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>picker didFinishPickingMediaWithInfo<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>info <span style="color: #002200;">&#123;</span>
	<span style="color: #002200;">&#91;</span>picker dismissModalViewControllerAnimated<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
	imageView.image <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>info objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;UIImagePickerControllerOriginalImage&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>The first line just hides the picker.  The next sets to <strong>image</strong> property of our image view to an image returned from the picker.  The picker actually returns an NSDictionary.  That is because the other key <a href="http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIImagePickerControllerDelegate_Protocol/UIImagePickerControllerDelegate/UIImagePickerControllerDelegate.html#//apple_ref/doc/c_ref/UIImagePickerControllerMediaType">UIImagePickerControllerMediaType</a>; will return whether this is a video or an image.</p>
<p>And there you have it.  A way to get photos from the iPhone&#8217;s image library or camera.  If you have any comments or questions, feel free to write them in the comments section of this post or <a href="http://twitter.com/brandontreb">write them to me on twitter</a>.  You can download the source below. Happy iCoding!</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/PhotoApp.zip">iPhone Tutorial &#8211; PhotoApp.zip</a></p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Programmatically Getting a Screencapture of any UIView</title>
		<link>http://icodeblog.com/2009/07/27/1188/</link>
		<comments>http://icodeblog.com/2009/07/27/1188/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 17:41:36 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1188</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/07/27/1188/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/07/Screenshots-150x150.png" class="alignleft wp-post-image tfe" alt="Screenshots" title="Screenshots" /></a>Introduction
Hey guys. This post is in response to a comment made in my last post about NSTimers. Techy asked if we could do a post on how to take screenshots programmatically using the iPhone SDK. For this minor project we will be creating a small web browser application that will start at www.google.com, and have [...]]]></description>
			<content:encoded><![CDATA[<h1><span style="color: #ff6600;">Introduction</span></h1>
<p>Hey guys. This post is in response to a comment made in my <a title="NSTimers: The Poor Mans Threading" href="http://icodeblog.com/2009/07/23/nstimer-the-poor-mans-threading-code-snapshot/" target="_blank">last post about NSTimers</a>. Techy asked if we could do a post on how to take screenshots programmatically using the iPhone SDK. For this minor project we will be creating a small web browser application that will start at www.google.com, and have a button on a toolbar at the bottom to take a picture of the web view and save it into you photo library. Lets take a look.</p>
<h1><a href="http://icodeblog.com/wp-content/uploads/2009/07/Screenshots.png"><img class="aligncenter size-full wp-image-1191" title="Screenshots" src="http://icodeblog.com/wp-content/uploads/2009/07/Screenshots.png" alt="Screenshots" width="465" height="457" /></a></h1>
<h1><span style="color: #ff6600;">Source</span></h1>
<p>You can get the source here: <a title="Screenshot Source" href="http://icodeblog.com/wp-content/uploads/2009/07/ScreenCapture.zip">Screenshot Project</a></p>
<h1><span style="color: #ff6600;">Steps</span></h1>
<h3><span style="color: #ff6600;">Step 1<br />
</span></h3>
<p>Create a view based application in xCode. Call it whatever.</p>
<h3><span style="color: #ff6600;">Step 2<br />
</span></h3>
<p>In the header for your view controller declare the following:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import </span>
&nbsp;
<span style="color: #a61390;">@interface</span> ScreenCaptureViewController <span style="color: #002200;">:</span> UIViewController
<span style="color: #002200;">&#123;</span>
	IBOutlet UIWebView <span style="color: #002200;">*</span>webview;
<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> IBOutlet UIWebView <span style="color: #002200;">*</span>webview;
&nbsp;
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span>IBAction<span style="color: #002200;">&#41;</span>captureScreen<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender;
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<h3><span style="color: #ff6600;">Step 3<br />
</span></h3>
<p>Open up your view controller&#8217;s XIB file.</p>
<ul>
<li>Drag in a UIToolbar and put it at the bottom of the screen.</li>
<li>Drag in a UIToolbarButtom and name it appropriately.</li>
<li>Drag in a flexible space holder on either side of the button to center it.</li>
<li>Drag in a UIWebView to take up the rest of the screen above the toolbar.</li>
<li>Connect the UIWebView to our webview IBOutlet.</li>
<li>Connect out UIToolbarButton to our IBAction catureScreen:(id)sender.</li>
</ul>
<h3><span style="color: #ff6600;">Step 4</span></h3>
<p>Uncomment out the viewDidLoad method and use the following code:</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: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad
<span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #002200;">&#91;</span>webview loadRequest<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURLRequest</span> requestWithURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.google.com&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<h3><span style="color: #ff6600;">Step 5<br />
</span></h3>
<h3><span style="color: #ff6600;"> </span></h3>
<p>All the is left to do is create the IBAction captureScreen. This is the code for the method, place it in the main file for your view controller.</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>IBAction<span style="color: #002200;">&#41;</span>captureScreen<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>sender
<span style="color: #002200;">&#123;</span>
	UIGraphicsBeginImageContext<span style="color: #002200;">&#40;</span>webview.frame.size<span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#91;</span>self.view.layer renderInContext<span style="color: #002200;">:</span>UIGraphicsGetCurrentContext<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
	UIImage <span style="color: #002200;">*</span>viewImage <span style="color: #002200;">=</span> UIGraphicsGetImageFromCurrentImageContext<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
	UIGraphicsEndImageContext<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
	UIImageWriteToSavedPhotosAlbum<span style="color: #002200;">&#40;</span>viewImage, <span style="color: #a61390;">nil</span>, <span style="color: #a61390;">nil</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<h1><span style="color: #ff6600;">Conclusion</span></h1>
<p>So that is it. You can use this general code to take a screenshot of any UIView subclass. All you need to do is replace webview.frame.size in the third line with foobar.frame.size where foobar is any UIView subclass. Hope this answered your question Techy. Happy Coding.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/07/27/1188/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>iPhone Programming Tutorial: Animating A Game Sprite</title>
		<link>http://icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/</link>
		<comments>http://icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 17:52:15 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[iPhone Game Programming]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone animation]]></category>
		<category><![CDATA[iPhone Coding]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1170</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/07/screenshot_011-150x150.png" class="alignleft wp-post-image tfe" alt="screenshot_01" title="screenshot_01" /></a>One thing I have noticed about many of the games in the app store is they lack animation.  Of course, the huge companies like Sega and PopCap have some pretty amazing animation, but what about us indie iPhone game developers?
[See post to watch QuickTime movie]
Well, Apple has made it quite simple to do animations. [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I have noticed about many of the games in the app store is they lack animation.  Of course, the huge companies like Sega and PopCap have some pretty amazing animation, but what about us indie iPhone game developers?</p>
<p><center>[See post to watch QuickTime movie]</center></p>
<p>Well, Apple has made it quite simple to do animations.  I really feel this method is often overlooked.  I will show you in just a few lines of code, how to completely animate your game images.  I will walk you through creating a simple application that uses animation.  If you don&#8217;t care about creating the app and just want the animation code, <a href="#animation">you can skip to this step</a>.  We will be making an animation of Ryu throwing some punches.</p>
<h2>1. Create  A View Based Application</h2>
<p>I&#8217;m not going to explain this one&#8230;</p>
<h2>2. Add These Images To Your Resources Folder</h2>
<p>Download<a href="http://icodeblog.com/wp-content/uploads/2009/07/ryu.zip">ryu.zip</a><a href="http://brandontreb.com/wp-content/uploads/2009/07/ryu1.zip"></a> and unzip it.  Then drag the unzipped files into your <strong>Resources</strong> folder.  Note: Sprite sheet downloaded from<a href="http://panelmonkey.org/"> http://panelmonkey.org/</a>.  This file contains 12 images of Ryu from Street Fighter punching.  It also has the background to Blanca&#8217;s stage just for fun.</p>
<h2>3. Create The Background</h2>
<p>You don&#8217;t have to do this step, it&#8217;s just to make it pretty.</p>
<p>Double click on <strong>whateveryoucalledyourapplicationViewController.xib</strong> to open it in Interface Builder.  Click the arrow button on the view to rotate it.  If you don&#8217;t what I am talking about, check out <a href="http://icodeblog.com/2009/07/09/integrating-twitter-into-your-applications/">this post</a>.</p>
<p>Drag a UIImageView on to the screen and stretch it to fill the entire iPhone screen.  In the Attributes inspector select <strong>sfst-blanka.jpg</strong>.  Make sure mode is set to <strong>center</strong> as this image has very low resolution. It should look something like this (I have added a black background color).</p>
<p style="text-align: center;"><img class="size-full wp-image-1175 aligncenter" title="screenshot_01" src="http://icodeblog.com/wp-content/uploads/2009/07/screenshot_011.png" alt="screenshot_01" width="480" height="342" /></p>
<h2>4. Creating The Animation</h2>
<p><a name="#animation"> </a></p>
<p>Open up <strong>yourApplicationViewController.m </strong>and add the following code to the <strong>viewDidLoad</strong> method.</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: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad <span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span> imageArray  <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSArray</span> alloc<span style="color: #002200;">&#93;</span> initWithObjects<span style="color: #002200;">:</span>
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;1.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;2.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;3.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;4.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;5.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;6.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;7.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;8.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;9.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;10.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;11.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #002200;">&#91;</span>UIImage imageNamed<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;12.png&quot;</span><span style="color: #002200;">&#93;</span>,
							<span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
	UIImageView <span style="color: #002200;">*</span> ryuJump <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImageView alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>
		CGRectMake<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">100</span>, <span style="color: #2400d9;">125</span>, <span style="color: #2400d9;">150</span>, <span style="color: #2400d9;">130</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;
	ryuJump.animationImages <span style="color: #002200;">=</span> imageArray;
	ryuJump.animationDuration <span style="color: #002200;">=</span> <span style="color: #2400d9;">1.1</span>;
	ryuJump.contentMode <span style="color: #002200;">=</span> UIViewContentModeBottomLeft;
	<span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>ryuJump<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>ryuJump startAnimating<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>For all of you &#8220;1337&#8243; coders that are going to post in the comments telling me &#8220;Why don&#8217;t you use a for loop to load the images&#8221; (very nerdy voice): I am doing it like this, so it is obvious what is going on.  I want to show that you must populate the array with images.</p>
<p>So here is what is going on in this code:</p>
<p>We first create an array of <strong>UIImage</strong>s.  Next, we allocate our <strong>UIImageView</strong>.<strong> </strong>The next part is where the magic happens&#8230; Apple has given you a property of UIImageView that is an array of images.  The UIImageView class has a built in functionality to cycle through images at a given interval (hence animating them).</p>
<p>The next variable we see is the animation duration.  This is the number of seconds it takes to cycle through all of the images.  The default value for this is the number of images multiplied by 1/30.  This will give you a 30 fps frame rate.  Since we have 12 images and not 30, this duration would make our Ryu look like he was on crack.</p>
<p>In our case, the default would be 12 * (1/30) or .4 . We are going to slow this down significantly to 1.1.  Go ahead and play with this number when creating your animation.</p>
<p>The next variable is the <strong>contentMode</strong>.  The content mode determines how the image will fit inside the UIImageView frame.  Since our animation images vary in size, we just make the frame as large as the largest image and set the contentMode to UIViewContentModeBottomLeft.  What this means is, draw the image withough scaling and place it in the bottom left of the UIImageView.  Read up on contentMode to figure out what will be right for your applicaiton.</p>
<p>Finally, we just add the UIImageView to our main view and call the <strong>startAnimating </strong>method on it.  This will start the animation of these images.  There are also some other helpful methods you might use when doing animation.  They include <strong>stopAnimating</strong> and <strong>isAnimating</strong>.</p>
<h2>5. Make Sure The Device Starts In Landscape Mode</h2>
<p>In this example, we assumed that the device was in landscape mode.  Again, read <a href="../2009/07/09/integrating-twitter-into-your-applications/">this post</a> to see how to do this.  It involves adding<strong> Initial interface orientation</strong> to the info.plist file and adding this code to your viewController.m file.</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: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>shouldAutorotateToInterfaceOrientation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIInterfaceOrientation<span style="color: #002200;">&#41;</span>interfaceOrientation <span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// Return YES for supported orientations</span>
    <span style="color: #a61390;">return</span> <span style="color: #002200;">&#40;</span>interfaceOrientation <span style="color: #002200;">==</span> UIInterfaceOrientationLandscapeLeft<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>That concludes our simple animation tutorial.  Post a question or <a href="http://twitter.com/brandontreb">ask me on Twitter</a> if you need help.  You can download the source for this tutorial <a href="http://icodeblog.com/wp-content/uploads/2009/07/AnimationApp.zip">here</a>. Happy iCoding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
<enclosure url="http://icodeblog.com/wp-content/uploads/2009/07/RuyPunch.mov" length="349110" type="video/quicktime" />
		</item>
		<item>
		<title>NSTimer: The Poor Man&#8217;s Threading &#8211; Code Snapshot</title>
		<link>http://icodeblog.com/2009/07/23/nstimer-the-poor-mans-threading-code-snapshot/</link>
		<comments>http://icodeblog.com/2009/07/23/nstimer-the-poor-mans-threading-code-snapshot/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 18:28:26 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[NSTimer]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1152</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/07/23/nstimer-the-poor-mans-threading-code-snapshot/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-16-150x150.png" class="alignleft wp-post-image tfe" alt="Picture 16" title="Picture 16" /></a>Introduction
Hey guys. So usually the posts we put up here involve screencasts and presentations, but we are going to start also posting small less time consuming pieces for the site. Today I bring to you a small project involving NSTimers. Today we are going to build an app that represents a horse race. We will [...]]]></description>
			<content:encoded><![CDATA[<h1><span style="color: #ff6600;">Introduction</span></h1>
<p>Hey guys. So usually the posts we put up here involve screencasts and presentations, but we are going to start also posting small less time consuming pieces for the site. Today I bring to you a small project involving NSTimers. Today we are going to build an app that represents a horse race. We will create a view with 6 small UIView squares with a blue background at the bottom of the screen, we will use a timer to move a random one of them forward a random amount of distance. Let&#8217;s get started!</p>
<p><a href="http://icodeblog.com/wp-content/uploads/2009/07/Picture-16.png"><img class="aligncenter size-full wp-image-1164" title="Picture 16" src="http://icodeblog.com/wp-content/uploads/2009/07/Picture-16.png" alt="Picture 16" width="351" height="693" /></a></p>
<h1><span style="color: #ff6600;">Source</span></h1>
<p>You can get the source here: <a href="http://icodeblog.com/wp-content/uploads/2009/07/NSTimerDemo.zip">NSTimerDemo</a></p>
<h1><span style="color: #ff6600;">Steps</span></h1>
<h3><span style="color: #ff6600;">Step 1<br />
</span></h3>
<p>Create a view based application in xCode. Call it whatever.</p>
<h3><span style="color: #ff6600;">Step 2<br />
</span></h3>
<p>In your view controller class header file add:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSTimer</span> <span style="color: #002200;">*</span>myTimer;</pre></div></div>

<h3><span style="color: #ff6600;">Step 3<br />
</span></h3>
<p>In your view controller class, uncomment out the viewDidLoad method and fill in the following code:</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: #a61390;">void</span><span style="color: #002200;">&#41;</span>viewDidLoad
<span style="color: #002200;">&#123;</span>
      <span style="color: #002200;">&#91;</span>super viewDidLoad<span style="color: #002200;">&#93;</span>;
&nbsp;
      CGRect workingFrame;
      workingFrame.origin.x <span style="color: #002200;">=</span> <span style="color: #2400d9;">15</span>;
      workingFrame.origin.y <span style="color: #002200;">=</span> <span style="color: #2400d9;">400</span>;
      workingFrame.size.width <span style="color: #002200;">=</span> <span style="color: #2400d9;">40</span>;
      workingFrame.size.height <span style="color: #002200;">=</span> <span style="color: #2400d9;">40</span>;
&nbsp;
      <span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> i <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i <span style="color: #002200;">&amp;</span>lt; <span style="color: #2400d9;">6</span>; i<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span>
      <span style="color: #002200;">&#123;</span>
           UIView <span style="color: #002200;">*</span>myView <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIView alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>workingFrame<span style="color: #002200;">&#93;</span>;
           <span style="color: #002200;">&#91;</span>myView setTag<span style="color: #002200;">:</span>i<span style="color: #002200;">&#93;</span>;
           <span style="color: #002200;">&#91;</span>myView setBackgroundColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor blueColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
           workingFrame.origin.x <span style="color: #002200;">=</span> workingFrame.origin.x <span style="color: #002200;">+</span> workingFrame.size.width <span style="color: #002200;">+</span> <span style="color: #2400d9;">10</span>;
           <span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>myView<span style="color: #002200;">&#93;</span>;
      <span style="color: #002200;">&#125;</span>
&nbsp;
      myTimer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSTimer</span> scheduledTimerWithTimeInterval<span style="color: #002200;">:</span>.1 target<span style="color: #002200;">:</span>self selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>moveACar<span style="color: #002200;">&#41;</span> userInfo<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> repeats<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
  <span style="color: #002200;">&#125;</span></pre></div></div>

<h3><span style="color: #ff6600;">Step 4<br />
</span></h3>
<h3><span style="color: #ff6600;"> </span></h3>
<p>In your view controller class, add the following method:</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: #a61390;">void</span><span style="color: #002200;">&#41;</span>moveACar
<span style="color: #002200;">&#123;</span>
      <span style="color: #a61390;">int</span> r <span style="color: #002200;">=</span> <span style="color: #a61390;">rand</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">%</span> <span style="color: #2400d9;">6</span>;
      NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;My number is %d&quot;</span>, r<span style="color: #002200;">&#41;</span>;
&nbsp;
      <span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span>UIView <span style="color: #002200;">*</span>aView <span style="color: #a61390;">in</span> <span style="color: #002200;">&#91;</span>self.view subviews<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
      <span style="color: #002200;">&#123;</span>
           <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>aView tag<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> r<span style="color: #002200;">&#41;</span>
           <span style="color: #002200;">&#123;</span>
                <span style="color: #a61390;">int</span> movement <span style="color: #002200;">=</span> <span style="color: #a61390;">rand</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">%</span> <span style="color: #2400d9;">100</span>;
                CGRect workingFrame <span style="color: #002200;">=</span> aView.frame;
                workingFrame.origin.y <span style="color: #002200;">=</span> workingFrame.origin.y <span style="color: #002200;">-</span> movement;
&nbsp;
                <span style="color: #002200;">&#91;</span>UIView beginAnimations<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> context<span style="color: #002200;">:</span><span style="color: #a61390;">NULL</span><span style="color: #002200;">&#93;</span>;
                <span style="color: #002200;">&#91;</span>UIView setAnimationDuration<span style="color: #002200;">:</span>.2<span style="color: #002200;">&#93;</span>;
                <span style="color: #002200;">&#91;</span>aView setFrame<span style="color: #002200;">:</span>workingFrame<span style="color: #002200;">&#93;</span>;
                <span style="color: #002200;">&#91;</span>UIView commitAnimations<span style="color: #002200;">&#93;</span>;
&nbsp;
                <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>workingFrame.origin.y <span style="color: #002200;">&amp;</span>lt; <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>
                <span style="color: #002200;">&#123;</span>
                    <span style="color: #002200;">&#91;</span>myTimer invalidate<span style="color: #002200;">&#93;</span>;
                <span style="color: #002200;">&#125;</span>
           <span style="color: #002200;">&#125;</span>
      <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span></pre></div></div>

<h1><span style="color: #ff6600;">Conclusion</span></h1>
<p>So that is it. Timers are really cool and come in handy for all sorts of small problems in a project. Happy coding.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/07/23/nstimer-the-poor-mans-threading-code-snapshot/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Voices That Matter iPhone Conference &#124; Special iCodeBlog Reader Discount</title>
		<link>http://icodeblog.com/2009/07/22/voices-that-matter-iphone-conference-special-icodeblog-reader-discount/</link>
		<comments>http://icodeblog.com/2009/07/22/voices-that-matter-iphone-conference-special-icodeblog-reader-discount/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 16:35:01 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[iPhone Articles]]></category>
		<category><![CDATA[Awesomeness]]></category>
		<category><![CDATA[iphone conference]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1143</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/07/22/voices-that-matter-iphone-conference-special-icodeblog-reader-discount/"><img align="left" hspace="5" width="150" src="http://icodeblog.com/wp-content/uploads/2009/07/150x150JoinMeiPhoneVTM.jpg" class="alignleft wp-post-image tfe" alt="150x150JoinMeiPhoneVTM" title="150x150JoinMeiPhoneVTM" /></a>
Calling all iPhone Developers.  Pearson Education has hooked iCodeBlog up with a sweet discount to this year&#8217;s Voices That Matter iPhone developers conference.  The conference will take place in Boston starting October 17th.  Here is some info from them (Including a coupon code for our readers)
Coming to you direct from Addison-Wesley Professional, which has published [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.voicesthatmatter.com/iphone2009/"><img class="size-full wp-image-1144 aligncenter" title="150x150JoinMeiPhoneVTM" src="http://icodeblog.com/wp-content/uploads/2009/07/150x150JoinMeiPhoneVTM.jpg" alt="150x150JoinMeiPhoneVTM" width="150" height="150" /></a></p>
<p>Calling all iPhone Developers.  Pearson Education has hooked iCodeBlog up with a sweet discount to this year&#8217;s Voices <a href="http://www.voicesthatmatter.com/iphone2009/">That Matter iPhone developers conference</a>.  The conference will take place in Boston starting October 17th.  Here is some info from them (<strong>Including a coupon code for our readers</strong>)</p>
<blockquote><p>Coming to you direct from Addison-Wesley Professional, which has published some of the leading books in the field, the <a href="http://www.voicesthatmatter.com/iphone2009/">Voices That Matter: iPhone Developers Conference</a> is taking place October 17-18 in Boston! This conference is designed for Mac developers looking for a succinct, easy way to get up to speed on the specific skills needed to build, test and distribute successful applications for the iPhone and iPod touch. <strong>Erica Sadun, author of The iPhone Developer’s Cookbook and our event’s technical chair, will lead an</strong> <a href="http://iphone2009.crowdvine.com/calendar">epic group of speakers</a> at the conference including Aaron Hillegass, Andy Ihnatko, Jon Rentzsch, Steve Kochan, Fraser Speirs, Lee Barney and lots of others. At this unique event, you will:</p>
<ul>
<li>Learn the skills needed to build, test, and distribute successful applications for the iPhone and iPod Touch</li>
<li>Choose the session topics you need to become an iPhone development master</li>
<li>Network with developers equally as passionate about this exciting platform and where its going</li>
<li>Leverage your existing skills in a new and profitable way</li>
</ul>
<p><span style="text-decoration: underline;"><strong>SPECIAL SAVINGS! </strong></span>As someone that reads this blog, you can save $100 on your conference registration by providing priority code PHBLOG when registering. <a href="http://www.voicesthatmatter.com/iphone2009/register.aspx">Register</a> <strong>before September 12th and save a total of $300</strong> as this $100 discount is combined with the early bird pricing!</p></blockquote>
<p>Just in case you were too lazy to read that copy, the coupon code is: <strong>PHBLOG</strong></p>
<p>I will be there for sure and would love to meet some of the readers in person. Hope to see you there. Happy iCoding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/07/22/voices-that-matter-iphone-conference-special-icodeblog-reader-discount/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Code Snippet: Prevent The iPhone From Sleeping</title>
		<link>http://icodeblog.com/2009/07/22/code-snippet-prevent-the-iphone-from-sleeping/</link>
		<comments>http://icodeblog.com/2009/07/22/code-snippet-prevent-the-iphone-from-sleeping/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 16:11:11 +0000</pubDate>
		<dc:creator>brandontreb</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[idletimerdisabled]]></category>
		<category><![CDATA[prevent iphone sleeping]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1138</guid>
		<description><![CDATA[<a href="http://icodeblog.com/2009/07/22/code-snippet-prevent-the-iphone-from-sleeping/"><img align="left" hspace="5" width="150" height="150" src="http://icodeblog.com/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>The code below will prevent the iPhone from dimming its screen and ultimately going to sleep.  Use it wisely as you don&#8217;t want your application becoming notorious for being a battery hog  

&#91;UIApplication sharedApplication&#93;.idleTimerDisabled = YES;

Happy iCoding!
]]></description>
			<content:encoded><![CDATA[<p>The code below will prevent the iPhone from dimming its screen and ultimately going to sleep.  Use it wisely as you don&#8217;t want your application becoming notorious for being a battery hog <img src='http://icodeblog.com/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;">&#91;</span>UIApplication sharedApplication<span style="color: #002200;">&#93;</span>.idleTimerDisabled <span style="color: #002200;">=</span> <span style="color: #a61390;">YES</span>;</pre></div></div>

<p>Happy iCoding!</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/07/22/code-snippet-prevent-the-iphone-from-sleeping/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 5.149 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-02-09 05:46:13 -->
