<?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>Lon Hosford &#187; Objective C</title>
	<atom:link href="http://www.lonhosford.com/lonblog/category/technologies/apple/objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lonhosford.com/lonblog</link>
	<description>Digital Media Solutions Expert</description>
	<lastBuildDate>Mon, 01 Apr 2013 15:47:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Tap, Move, Shake: Turning Your Game Ideas into iPhone &amp; iPad Apps</title>
		<link>http://www.lonhosford.com/lonblog/2012/01/22/tap-move-shake-turning-your-game-ideas-into-iphone-ipad-apps/</link>
		<comments>http://www.lonhosford.com/lonblog/2012/01/22/tap-move-shake-turning-your-game-ideas-into-iphone-ipad-apps/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 21:51:10 +0000</pubDate>
		<dc:creator>Lon Hosford</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[IPhone]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.lonhosford.com/lonblog/?p=2845</guid>
		<description><![CDATA[Todd Moore&#8217;s new book, Tap, Move, Shake: Turning Your Game Ideas into iPhone &#038; iPad Apps, is currently the best choice for getting started with writing and publishing IOS games. A key feature is that the apps in the book are IN THE APP STORE. Never saw that trick before and I think is a [...]]]></description>
				<content:encoded><![CDATA[<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2012/01/22/tap-move-shake-turning-your-game-ideas-into-iphone-ipad-apps/" send="true" width="450" show_faces="true" font=""></fb:like><!-- Place this tag where you want the +1 button to render --><br />
<g:plusone annotation="inline"></g:plusone></p>
<p>Todd Moore&#8217;s new book, <strong><a href="http://www.amazon.com/gp/product/1449303455/ref=as_li_ss_tl?ie=UTF8&#038;tag=hosfordusa&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1449303455">Tap, Move, Shake: Turning Your Game Ideas into iPhone &#038; iPad Apps</a></strong>, is currently the best choice for getting started with writing and publishing IOS games. </p>
<p>A key feature is that <strong>the apps in the book are IN THE APP STORE</strong>. Never saw that trick before and I think is a standard for anyone writing IOS books. I actually followed the steps of creating an app I could download suffice it had a tad more flash in the store.</p>
<div class="wp-caption alignleft" style="width: 131px"><a href="http://www.amazon.com/gp/product/1449303455/ref=as_li_ss_tl?ie=UTF8&#038;tag=hosfordusa&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1449303455" target="_blank"><img  src="http://ecx.images-amazon.com/images/I/51erZvLUPaL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA300_SH20_OU01_.jpg" alt="Tap, Move, Shake: Turning Your Game Ideas into iPhone &#038; iPad Apps" width="121" height="160" class="  " title="Tap, Move, Shake: Turning Your Game Ideas into iPhone &#038; iPad Apps"/></a><p class="wp-caption-text">Tap, Move, Shake: Turning Your Game Ideas into iPhone &#038; iPad Apps</p></div>
<p>This is the first book I have seen in XCode/ObjectiveC that takes the submission to the App store as important a learning step as is the process of writing code. I loved the give and take App store rejection emails that provided a lot of insight for anyone who is going to submit an app the first time.</p>
<p>Also insightful is the special effort in giving the coder who is light on media creation great chapters on creating graphics and sound. Links provided are well researched.</p>
<p>On the wish list for me was not to dismiss ARC (Automatic Reference Counting) at the onset. Gee the book kinda assumes the beginner and ARC leans to that. But I suspect a case of examples completed at a time Apple was busy upsetting the cart for writers in progress.</p>
<p>The chapters are extremely well thought out especially the progression of development with the sections in each chapter. </p>
<p>I think you need a basic skill in XCode and Objective C to follow the book. XCode is introduced nicely for beginners and Objective C is learned more by example and less by explanation. I could not have solved some bugs without a basic skill in Objective C. The architecture of IOS app is explained well. I loved the clarity of explaining the bootstrap of an IOS app. I finally got it!</p>
<p>The book covers EVERYTHING you need from setting up for development, coding, basic testing, resource creation, app submission and even app marketing. All at a very clear to the point approach. The book examples make you feel you are starting at the beginning because they are from the gaming industry beginnings tuned to the phone.</p>
<p>This is 254 page book that has a good number of images taking up pages. Compared to 3 and 4 inch opus magnum IOS books out there that are OMGs difficult to hold open on the desk or in a lounge chair, Todd gets a great deal done as a focused writer. Cutting content is key. I rather buy more books than have big monsters.</p>
<p>Want to get started in IOS gaming without a gaming engine or better understand your gaming engine, then do this book.</p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2012/01/22/tap-move-shake-turning-your-game-ideas-into-iphone-ipad-apps/" send="true" width="450" show_faces="true" font=""></fb:like></p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="http://www.lonhosford.com/lonblog/2012/01/22/tap-move-shake-turning-your-game-ideas-into-iphone-ipad-apps/" num_posts="3" width="500"></fb:comments></p>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><br />
<!-- Place this render call where appropriate --><br />
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lonhosford.com/lonblog/2012/01/22/tap-move-shake-turning-your-game-ideas-into-iphone-ipad-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XCode 4 IPhone Mountains of the USA Tutorial: Lesson 9 &#8211; Add Annotation to MapView</title>
		<link>http://www.lonhosford.com/lonblog/2011/05/27/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-9-add-annotation-to-mapview/</link>
		<comments>http://www.lonhosford.com/lonblog/2011/05/27/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-9-add-annotation-to-mapview/#comments</comments>
		<pubDate>Fri, 27 May 2011 21:03:21 +0000</pubDate>
		<dc:creator>Lon Hosford</dc:creator>
				<category><![CDATA[IPhone]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.lonhosford.com/lonblog/?p=2293</guid>
		<description><![CDATA[&#60;== Lesson 8 &#124;&#124; Overview &#124;&#124; This lesson adds an annotation and pin on the map to better show the location of the mountain. MapAnnotation class is all that you need to get a pin on the map with an annotation above it. However, you may want the annotation and pin to &#8220;drop in&#8221; or [...]]]></description>
				<content:encoded><![CDATA[<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" send="true" width="450" show_faces="true" font=""></fb:like><br />
<a href="http://www.lonhosford.com/lonblog/2011/05/26/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-8-add-mapview/">&lt;== Lesson 8</a> || <a href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/">Overview</a>  || </p>
<p>This lesson adds an annotation and pin on the map to better show the location of the mountain.<img class="alignleft" src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/TcVF8NRLevI/AAAAAAAAF2U/dZ3fASCSYCA/s800/USAMountainsBlogImage.png" alt="" width="160" height="218" /> </p>
<div class="wp-caption alignright" style="width: 215px"><img class=" " style="border: 0pt none;" src="https://lh4.googleusercontent.com/-RPlURqMGoWU/Td_4JS6HLHI/AAAAAAAAGBs/7kzFH8FfuNs/s400/USAMountains09Screen02b.png" alt="" width="205" height="400" /><p class="wp-caption-text">Detail View with MapView Annotation</p></div>
<p>MapAnnotation class is all that you need to get a pin on the map with an annotation above it. </p>
<p>However, you may want the annotation and pin to &#8220;drop in&#8221; or you might want to control the pin color. This requires a MKMapViewDelegate class and the viewForAnnotation method. In this method a MKPinAnnotationView object is created to embellish the annotation with more functionality as well as the &#8220;drop in&#8221; effect. The DetailViewController class will serve as the MKMapViewDelegate.</p>
<p>As you proceed through the steps, the code items not needed to &#8220;just show an annotation and pin&#8221; are identified for you so you can try an example without the special drop in effect. To summarize that approach in advance, you do not need to add the MKMapViewDelegate protocol to your DetailViewController.h file, you exclude the <code>[mapView setDelegate:self];</code> line from the <code>viewWillAppear</code> method in the DetailViewContoller.m files and you will not need the <code>viewForAnnotation</code> method added in step 3.</p>
<p><strong>Source Download</strong></p>
<ol>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial08.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial08.zip">Starting XCode 4 Project</a>. This is the lesson 8 project completed.</li>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial02PHP_CSV_files.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial02PHP_CSV_files.zip">PHP and CSV Files</a>. Script to read data file and selects by elevation and returns XML. <a href="http://www.lonhosford.com/lonblog/2011/05/12/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-2-load-xml-data/"> See Lesson 2</a>.</li>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial09.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial09.zip">Completed XCode 4 Project</a></li>
</ol>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p><strong>Step 1: DetailViewController.h &#8211; Add the MKMapViewDelegate Protocol</strong><br />
Download and uncompress the <a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial08.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial08.zip">Starting XCode Project</a> file and open in XCode.</p>
<p>Open the DetailViewController.h class and add line 3 to include the MapAnnotation header. </p>
<p>On line 6 you need to edit in the MKMapViewDelegate protocol. This line is needed only if you want more functionality over the annotation such as pin color or a &#8220;drop in&#8221; effect by including the viewForAnnotation method. </p>
<pre class="brush: objc; highlight: [3,6]; title: ; notranslate">
#import &lt;UIKit/UIKit.h&gt;
#import &lt;MapKit/Mapkit.h&gt;
#import &quot;MapAnnotation.h&quot;
#import &quot;MountainItem.h&quot;


@interface DetailViewController : UIViewController &lt;MKMapViewDelegate&gt;{
    MKMapView *mapView;
    
    MountainItem *mountainItem;
}

@property (nonatomic, retain) IBOutlet MKMapView *mapView;

@property (nonatomic, retain) MountainItem *mountainItem;

@end
</pre>
<p><strong>Step 2: DetailViewController.m &#8211; Create the Annotation</strong><br />
Open the DetailViewController.m file.</p>
<p>The first 51 lines of code are not changing but included here for online reference:</p>
<pre class="brush: objc; collapse: true; light: false; title: ; toolbar: true; notranslate">
#import &quot;DetailViewController.h&quot;


@implementation DetailViewController
@synthesize mapView;
@synthesize mountainItem;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [mapView dealloc];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.mapView = nil;
    
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

</pre>
<p>Add the highlighed line in the next code view.</p>
<p>Line 68 sets this class to receive MKMapViewDelegate messages. In the last step you defined this class as MKMapViewDelegate.</p>
<p>Line 68 is not needed if all you want to show the annotation and pin without any special view or effects. A MKMapViewDelegate is not needed for that.</p>
<p>Line 70 clears all annotations from the map. You can leave this line out and the previous pins and their annotations will stay on the map. If you try some mountains in the same range or zoom way out, you will see the previous pins and when you touch the pin the annotation will appear.</p>
<p>Lines 71 to 73 create the annotation object, give it a title and position in the center of the view region created in the last lesson on lines 61 to 66.</p>
<p>The annotation is added to the map on line 75.</p>
<p>The annotation is selected on line 77. When you test the app, you should touch the annotation and the pin. You will see the selected and unselected state. Unselected, just a pin appears. Selected the title appears. Line 77 is achieving the selection process in code.</p>
<p>Line 78 is clean up.</p>
<pre class="brush: objc; first-line: 52; highlight: [68,70,71,72,73,75,77,78]; title: ; notranslate">
-(void)viewWillAppear:(BOOL)animated 
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [self setTitle:mountainItem.name];

    [mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
    region.center.latitude = [mountainItem.latitude doubleValue] ;
    region.center.longitude = [mountainItem.longitude doubleValue] ;
    region.span.longitudeDelta = 1.0f;
    region.span.latitudeDelta = 1.0f;
    [mapView setRegion:region animated:YES];
    
    [mapView setDelegate:self];
    
    [self.mapView removeAnnotations:self.mapView.annotations];
    MapAnnotation *ann = [[MapAnnotation alloc] init];
    ann.title = mountainItem.name;
    ann.coordinate = region.center;
    
    [mapView addAnnotation:ann];
    
    [mapView selectAnnotation:ann animated:YES];  
    [ann release];
}
</pre>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p><strong>Step 3: DetailViewController.m &#8211; Add Annotation View and Drop In Effect</strong></p>
<p>The viewForAnnotation method is called to develop the view for an annotation. </p>
<div style = "font-size:10px;padding-left:25px;padding-right:25px"> This implementation is simple because we only have one annotation. The method is called for all annotations. With multiple annotation, you may need to treat certain annotations differently, so you might need to identify which is calling this method. As well if you are using a unpredictable number of annotations and some annotations persist, this is a place to determine how to reuse MKPinAnnotationView objects. All of this is beyond the scope of the tutorial, but this explains why you will see more lines of code in other examples and why this example appears simpler.</div>
<p>Line 83 creates the MKPinAnnotationView annView object. You are going to reuse the same MKPinAnnotationView, so the identifier MyPin is created to help that happen. </p>
<p>The pin &#8220;drop in&#8221; effect occurs because of line 84.</p>
<p>Line 85 is needed to show the pin annotation title. There are more items that can be added to the annotation such as a subtitle and left and right views. </p>
<p>The pin color is set on line 87. You can use MKPinAnnotationColorGreen and MKPinAnnotationColorPurple. These and MKPinAnnotationColorRed were added in IOS 3.0.</p>
<pre class="brush: objc; first-line: 80; highlight: [80,81,82,83,84,85,86,87,88,89,90]; title: ; notranslate">
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id &lt;MKAnnotation&gt;) annotation

{
    MKPinAnnotationView *annView = [[[MKPinAnnotationView alloc ] initWithAnnotation:annotation reuseIdentifier:@&quot;MyPin&quot;] autorelease] ;
    annView.animatesDrop=TRUE;
    annView.canShowCallout = YES;
      
	annView.pinColor = MKPinAnnotationColorRed;
    
    return annView;
}
</pre>
<p>Try in the simulator. Tap the annotations and the pins to get the feel for them.</p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" send="true" width="450" show_faces="true" font=""></fb:like></p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" num_posts="2" width="500"></fb:comments></p>
<p><!-- Begin MailChimp Signup Form --><br />
<!--[if IE]></p>
<style type="text/css" media="screen">
	#mc_embed_signup fieldset {position: relative;}
	#mc_embed_signup legend {position: absolute; top: -1em; left: .2em;}
</style>
<p><![endif]--><br />
<!--[if IE 7]></p>
<style type="text/css" media="screen">
	.mc-field-group {overflow:visible;}
</style>
<p><![endif]--></p>
<div id="mc_embed_signup">
<form action="http://clicksystemsconsulting.us1.list-manage.com/subscribe/post?u=1d83b555f8b0ae0bef0eda6b7&amp;id=73cb4b1340" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" style="font: normal 100% Arial, sans-serif;font-size: 12pxpx;">
<fieldset style="-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;border: 1px solid #000000;padding-top: 1.5em;margin: .5em 0;background-color: #FFFFFF;color: #333333;text-align: left;">
<legend style="white-space: normal;text-transform: capitalize;font-weight: bold;color: #666666;background: #CCCCCC;padding: .5em 1em;border: 1px solid #000000;-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;font-size: 1.2em;"><span>Register For Updates</span></legend>
<div style="padding-left:15px"> You can opt out at anytime</div>
<div class="indicate-required" style="text-align: right;font-style: italic;overflow: hidden;color: #333333;margin: 0 9% 0 0;">* indicates required</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-EMAIL" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Email Address <strong class="note-required">*</strong><br />
</label><br />
<input type="text" value="" name="EMAIL" class="required email" id="mce-EMAIL" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-FNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">First Name </label><br />
<input type="text" value="" name="FNAME" class="" id="mce-FNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-LNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Last Name </label><br />
<input type="text" value="" name="LNAME" class="" id="mce-LNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;display: none;">
    <label class="input-group-label" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Group </label></p>
<div class="input-group" style="padding: .7em .7em .7em 0;font-size: .9em;margin: 0 0 1em 0;">
<ul style="margin: 0;padding: 0;">
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" value="1" name="group[1][1]" id="mce-group[1]-1-0" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-0" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">RVCC Course Student</label></li>
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" checked value="2" name="group[1][2]" id="mce-group[1]-1-1" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-1" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">XCode IPhone Mountains Tutorial</label></li>
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" checked value="4" name="group[1][4]" id="mce-group[1]-1-2" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-2" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">New Blog Articles</label></li>
</ul></div>
</div>
<div id="mce-responses" style="float: left;top: -1.4em;padding: 0em .5em 0em .5em;overflow: hidden;width: 90%;margin: 0 5%;clear: both;">
<div class="response" id="mce-error-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;float: left;top: -1.5em;z-index: 1;width: 80%;background: FBE3E4;color: #D12F19;"></div>
<div class="response" id="mce-success-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;float: left;top: -1.5em;z-index: 1;width: 80%;background: #E3FBE4;color: #529214;"></div>
</p></div>
<div><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn" style="clear: both;width: auto;display: block;margin: 1em 0 1em 5%;"></div>
</fieldset>
<p>	<a href="#" id="mc_embed_close" class="mc_embed_close" style="display: none;">Close</a><br />
</form>
</div>
<p><script type="text/javascript">
var fnames = new Array();var ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';
try {
    var jqueryLoaded=jQuery;
    jqueryLoaded=true;
} catch(err) {
    var jqueryLoaded=false;
}
var head= document.getElementsByTagName('head')[0];
if (!jqueryLoaded) {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js';
    head.appendChild(script);
    if (script.readyState &#038;&#038; script.onload!==null){
        script.onreadystatechange= function () {
              if (this.readyState == 'complete') mce_preload_check();
        }    
    }
}
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://downloads.mailchimp.com/js/jquery.form-n-validate.js';
head.appendChild(script);
var err_style = '';
try{
    err_style = mc_custom_error_style;
} catch(e){
    err_style = 'margin: 1em 0 0 0; padding: 1em 0.5em 0.5em 0.5em; background: FFEEEE none repeat scroll 0% 0%; font-weight: bold; float: left; z-index: 1; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: FF0000;';
}
var head= document.getElementsByTagName('head')[0];
var style= document.createElement('style');
style.type= 'text/css';
if (style.styleSheet) {
  style.styleSheet.cssText = '.mce_inline_error {' + err_style + '}';
} else {
  style.appendChild(document.createTextNode('.mce_inline_error {' + err_style + '}'));
}
head.appendChild(style);
setTimeout('mce_preload_check();', 250);</p>
<p>var mce_preload_checks = 0;
function mce_preload_check(){
    if (mce_preload_checks>40) return;
    mce_preload_checks++;
    try {
        var jqueryLoaded=jQuery;
    } catch(err) {
        setTimeout('mce_preload_check();', 250);
        return;
    }
    try {
        var validatorLoaded=jQuery("#fake-form").validate({});
    } catch(err) {
        setTimeout('mce_preload_check();', 250);
        return;
    }
    mce_init_form();
}
function mce_init_form(){
    jQuery(document).ready( function($) {
      var options = { errorClass: 'mce_inline_error', errorElement: 'div', onkeyup: function(){}, onfocusout:function(){}, onblur:function(){}  };
      var mce_validator = $("#mc-embedded-subscribe-form").validate(options);
      options = { url: 'http://clicksystemsconsulting.us1.list-manage1.com/subscribe/post-json?u=1d83b555f8b0ae0bef0eda6b7&#038;id=73cb4b1340&#038;c=?', type: 'GET', dataType: 'json', contentType: "application/json; charset=utf-8",
                    beforeSubmit: function(){
                        $('#mce_tmp_error_msg').remove();
                        $('.datefield','#mc_embed_signup').each(
                            function(){
                                var txt = 'filled';
                                var fields = new Array();
                                var i = 0;
                                $(':text', this).each(
                                    function(){
                                        fields[i] = this;
                                        i++;
                                    });
                                $(':hidden', this).each(
                                    function(){
                                    	if ( fields[0].value=='MM' &#038;&#038; fields[1].value=='DD' &#038;&#038; fields[2].value=='YYYY' ){
                                    		this.value = '';
									    } else if ( fields[0].value=='' &#038;&#038; fields[1].value=='' &#038;&#038; fields[2].value=='' ){
                                    		this.value = '';
									    } else {
	                                        this.value = fields[0].value+'/'+fields[1].value+'/'+fields[2].value;
	                                    }
                                    });
                            });
                        return mce_validator.form();
                    }, 
                    success: mce_success_cb
                };
      $('#mc-embedded-subscribe-form').ajaxForm(options);      </p>
<p>    });
}
function mce_success_cb(resp){
    $('#mce-success-response').hide();
    $('#mce-error-response').hide();
    if (resp.result=="success"){
        $('#mce-'+resp.result+'-response').show();
        $('#mce-'+resp.result+'-response').html(resp.msg);
        $('#mc-embedded-subscribe-form').each(function(){
            this.reset();
    	});
    } else {
        var index = -1;
        var msg;
        try {
            var parts = resp.msg.split(' - ',2);
            if (parts[1]==undefined){
                msg = resp.msg;
            } else {
                i = parseInt(parts[0]);
                if (i.toString() == parts[0]){
                    index = parts[0];
                    msg = parts[1];
                } else {
                    index = -1;
                    msg = resp.msg;
                }
            }
        } catch(e){
            index = -1;
            msg = resp.msg;
        }
        try{
            if (index== -1){
                $('#mce-'+resp.result+'-response').show();
                $('#mce-'+resp.result+'-response').html(msg);            
            } else {
                err_id = 'mce_tmp_error_msg';
                html = '
<div id="'+err_id+'" style="'+err_style+'"> '+msg+'</div>
<p>';</p>
<p>                var input_id = '#mc_embed_signup';
                var f = $(input_id);
                if (ftypes[index]=='address'){
                    input_id = '#mce-'+fnames[index]+'-addr1';
                    f = $(input_id).parent().parent().get(0);
                } else if (ftypes[index]=='date'){
                    input_id = '#mce-'+fnames[index]+'-month';
                    f = $(input_id).parent().parent().get(0);
                } else {
                    input_id = '#mce-'+fnames[index];
                    f = $().parent(input_id).get(0);
                }
                if (f){
                    $(f).append(html);
                    $(input_id).focus();
                } else {
                    $('#mce-'+resp.result+'-response').show();
                    $('#mce-'+resp.result+'-response').html(msg);
                }
            }
        } catch(e){
            $('#mce-'+resp.result+'-response').show();
            $('#mce-'+resp.result+'-response').html(msg);
        }
    }
}</p>
<p></script><br />
<!--End mc_embed_signup--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lonhosford.com/lonblog/2011/05/27/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-9-add-annotation-to-mapview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XCode 4 IPhone Mountains of the USA Tutorial: Lesson 8 &#8211; Add MapView</title>
		<link>http://www.lonhosford.com/lonblog/2011/05/26/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-8-add-mapview/</link>
		<comments>http://www.lonhosford.com/lonblog/2011/05/26/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-8-add-mapview/#comments</comments>
		<pubDate>Thu, 26 May 2011 17:58:40 +0000</pubDate>
		<dc:creator>Lon Hosford</dc:creator>
				<category><![CDATA[IPhone]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.lonhosford.com/lonblog/?p=2231</guid>
		<description><![CDATA[&#60;== Lesson 7 &#124;&#124; Overview &#124;&#124; Lesson 9 ==&#62; Now you have the second view added in the last lesson, you can add a map to show where the mountain is located. You can use the longitude and latitude that are part of the MountainItem data passed to the second view. To work with a [...]]]></description>
				<content:encoded><![CDATA[<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" send="true" width="450" show_faces="true" font=""></fb:like><br />
<a href="http://www.lonhosford.com/lonblog/2011/05/24/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-7-add-detail-view/">&lt;== Lesson 7</a> || <a href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/">Overview</a>  ||  <a href="http://www.lonhosford.com/lonblog/2011/05/27/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-9-add-annotation-to-mapview/">Lesson 9 ==&gt; </a>   </p>
<p>Now you have the second view added in the last lesson, you can add a map to show where the mountain is located.<img class="alignleft" src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/TcVF8NRLevI/AAAAAAAAF2U/dZ3fASCSYCA/s800/USAMountainsBlogImage.png" alt="" width="160" height="218" /> You can use the longitude and latitude that are part of the MountainItem data passed to the second view. </p>
<div class="wp-caption alignright" style="width: 215px"><img class=" " style="border: 0pt none;" src="https://lh6.googleusercontent.com/-V09mTAQSO-I/Td5DeSSiXNI/AAAAAAAAGBE/Eqy4pkICgH4/s400/USAMountains08Screen02.png" alt="" width="205" height="400" /><p class="wp-caption-text">Detail View Screen with MapView</p></div>
<p>To work with a map, you need to include the MapKit framework. There are frameworks included automatically with a new IOS XCode project. They are UIKit, Foundation and CoreGraphics. You have probably noticed the import statement for UIKit in the header for MainViewController and DetailViewController. </p>
<p>In XCode 4 a group called Frameworks contains the frameworks you include with your project. <div class="wp-caption none" style="width: 265px"><img class=" " src="https://lh5.googleusercontent.com/-QkzQwgHpdhY/Td4xu-mzMnI/AAAAAAAAGAo/IiPUKpgQpvo/s800/USAMountains08AddMapKitProjectFrameWorksBefore.png" alt="" width="255" height="83" /><p class="wp-caption-text">Typical Frameworks Group</p></div> </p>
<p>It is a good practice to assure any new ones you add are in that group for easy reference.</p>
<p><strong>Source Download</strong></p>
<ol>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial07.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial07.zip">Starting XCode 4 Project</a>. This is the lesson 7 project completed.</li>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial02PHP_CSV_files.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial02PHP_CSV_files.zip">PHP and CSV Files</a>. Script to read data file and selects by elevation and returns XML. <a href="http://www.lonhosford.com/lonblog/2011/05/12/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-2-load-xml-data/"> See Lesson 2</a>.</li>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial08.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial08.zip">Completed XCode 4 Project</a></li>
</ol>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p><strong>Step 1: Add the MapKit Framework</strong><br />
Download and uncompress the <a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial07.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial07.zip">Starting XCode Project</a> file and open in XCode.</p>
<p>In the project explorer select the top node.</p>
<div class="wp-caption aligncenter" style="width: 382px"><img class=" " src="https://lh6.googleusercontent.com/-g2JbysA23Pk/Td4xvXzqgaI/AAAAAAAAGAw/NWgMTtERoS0/s800/USAMountains08AddMapKitProjectNode.png" alt="" width="372" height="166" /><p class="wp-caption-text">Select Project Node</p></div>
<p>In the center of XCode follow these steps:</p>
<div class="wp-caption aligncenter" style="width: 650px"><img class=" " src="https://lh6.googleusercontent.com/-BB-Pkp8eCK4/Td4xux7osaI/AAAAAAAAGAs/tXRibhgC2H0/s640/USAMountains08AddMapKitBuildPhasesToAddButton.png" alt="" width="640" height="201" /><p class="wp-caption-text">Steps to Open Frameworks and Libraries Dialog</p></div>
<p>Type map into the search text field and you should see the list narrow down to the MapKit.framework choice and then select the Add button.</p>
<div class="wp-caption aligncenter" style="width: 286px"><img class=" " src="https://lh6.googleusercontent.com/-dClwnKvJ7wU/Td4xu3ZsdSI/AAAAAAAAGAk/TAtNQ4ltRw8/s400/USAMountains08AddMapKitChooseFramework.png" alt="" width="276" height="379" /><p class="wp-caption-text">Frameworks and Libraries Dialog</p></div>
<p>Locate the MapKit.framework file in the project explorer and drag it into the Frameworks group. You could leave MapKit.framework where it was grouped, but keeping the frameworks together makes sense.</p>
<div class="wp-caption aligncenter" style="width: 384px"><img class=" " src="https://lh6.googleusercontent.com/-WLrFU7j7hkg/Td4xuumdVRI/AAAAAAAAGAg/HmOJTG_ohUs/s800/USAMountains08AddMapKitProjectDragToFrameworks.png" alt="" width="374" height="238" /><p class="wp-caption-text">Drag MapKit Framework To Frameworks Group</p></div>
<p><strong>Step 2: DetailViewController.h &#8211; Replace TextView with MapView</strong></p>
<p>Open the DetailViewController.h file in the project explorer.</p>
<p>You are going to replace the UITextView with a MKMapView. Lines that are being replaced are included here for convenience.</p>
<pre class="brush: objc; collapse: true; highlight: [5,9]; light: false; title: ; toolbar: true; notranslate">
#import &lt;UIKit/UIKit.h&gt;
#import &quot;MountainItem.h&quot;

@interface DetailViewController : UIViewController {
    UITextView *mountainInfoTextView;
    
    MountainItem *mountainItem;
}
@property (nonatomic, retain) IBOutlet UITextView *mountainInfoTextView;

@property (nonatomic, retain) MountainItem *mountainItem;
@end
</pre>
<p>Line 2 below show the inclusion of MapKit in this class.</p>
<p>Lines 6 and 11 give you an IBOutlet to the MapView you add later to the DetailViewController.xib.</p>
<pre class="brush: objc; highlight: [2,6,11]; title: ; notranslate">
#import &lt;UIKit/UIKit.h&gt;
#import &lt;MapKit/Mapkit.h&gt;
#import &quot;MountainItem.h&quot;


@interface DetailViewController : UIViewController &lt;MKMapViewDelegate&gt;{
    MKMapView *mapView;
    
    MountainItem *mountainItem;
}

@property (nonatomic, retain) IBOutlet MKMapView *mapView;

@property (nonatomic, retain) MountainItem *mountainItem;

@end
</pre>
<p><strong>Step 3: DetailViewController.m &#8211; Add mapView Property to the Implementation</strong></p>
<p>Open the DetailViewController.m file in the project explorer.</p>
<p>These are the standard lines to include the mapView property to the implementation file. </p>
<p>You need to remove the mountainInfoTextView property and for convenience the lines are shown here. </p>
<pre class="brush: objc; collapse: true; highlight: [4,17,44]; light: false; title: ; toolbar: true; notranslate">
#import &quot;DetailViewController.h&quot;


@implementation DetailViewController
@synthesize mountainInfoTextView;
@synthesize mountainItem;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [mountainInfoTextView dealloc];
    [mountainItem dealloc];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.mountainInfoTextView = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
</pre>
<p>Include the lines below to add the mapView object.</p>
<pre class="brush: objc; highlight: [4,17,44]; title: ; notranslate">
#import &quot;DetailViewController.h&quot;


@implementation DetailViewController
@synthesize mapView;
@synthesize mountainItem;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [mapView dealloc];
    [mountainItem dealloc];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.mapView = nil;
    
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
</pre>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><br />
<strong>Step 4: DetailViewController.m &#8211; Show the Mountain&#8217;s Location on the Map</strong></p>
<p>Remove line 58 because you are replacing the mountainInfoTextView with the coding for the mapView.</p>
<pre class="brush: objc; collapse: true; first-line: 53; highlight: [58]; light: false; title: ; toolbar: true; notranslate">
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self setTitle:mountainItem.name];
     
    mountainInfoTextView.text = [NSString stringWithFormat: @&quot;Name: %@\nElevation: %f\nLatitude: %f\nLongitude: %f&quot;,mountainItem.name, [mountainItem.elevation floatValue],  [mountainItem.latitude floatValue], [mountainItem.longitude floatValue]]; 

}
@end
</pre>
<p>Add the highlighted lines in the next code view.</p>
<p>The standard map type is set on line 59. You could also use MKMapTypeSatellite and MKMapTypeHybrid if you want to experiment.</p>
<p>Lines 60 and 61 are self explanatory. </p>
<p>The zoom and center point of the map is done on lines 62 to 67. Then center point is the longitude and latitude data passed into the class in the mountainItem object. </p>
<p>The span is an offset for the zoom. You can experiment with positive float numbers such as .01 which will zoom in tight. Because many of the mountains do not have any feature in standard map view, the value of 1 seems to show enough map details to keep from being disoriented.</p>
<pre class="brush: objc; first-line: 53; highlight: [59,60,61,62,63,64,65,66,67]; title: ; notranslate">
-(void)viewWillAppear:(BOOL)animated 
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [self setTitle:mountainItem.name];

    [mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
    region.center.latitude = [mountainItem.latitude doubleValue] ;
    region.center.longitude = [mountainItem.longitude doubleValue] ;
    region.span.longitudeDelta = 1.0f;
    region.span.latitudeDelta = 1.0f;
    [mapView setRegion:region animated:YES];
    
}


@end
</pre>
<p><strong>Step 5: DetailViewController.xib &#8211; Replace the TextView with the MapView</strong></p>
<p>Open the DetailViewController.xib.</p>
<p>Delete the TextView in the design window.<br />
<div class="wp-caption aligncenter" style="width: 366px"><img class=" " src="https://lh3.googleusercontent.com/-gsU-8EMhBog/Td6NKY8jsDI/AAAAAAAAGBk/BbUVJIW1kwk/s800/USAMountainTutorial08DetailViewControllerDeleteTextView.png" alt="" width="356" height="234" /><p class="wp-caption-text">Delete TextView</p></div></p>
<p>Drag the MapView from the Objects panel to the view in the design window and fill the view.</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/-vpRPARYUUPY/Td6LXGQS2aI/AAAAAAAAGBc/Lmo78dS52ag/s400/USAMountainTutorial08DetailViewControllerDragMapView.png" alt="" width="400" height="183" /><p class="wp-caption-text">Drag MapView</p></div>
<p>With the MapView still selected open the Connections Inspector and drag a &#8220;New Referencing Outlet&#8221; to the File&#8217;s Owner and when you release the mouse select mapView, the name your are using in our DetailViewController to control the MapView. The Connections Inspector should look as follows:</p>
<div class="wp-caption aligncenter" style="width: 437px"><img class=" " src="https://lh5.googleusercontent.com/-eEFHZWTQkQE/Td4xvnvobaI/AAAAAAAAGA8/eiSAo6N5olA/s800/USAMountains08DetailViewControllerMapViewConnectionsInspector.png" alt="" width="427" height="145" /><p class="wp-caption-text">Connections Inspector For MapView</p></div>
<p>Then finally as a double check select the File&#8217;s Owner and the Connections Inspector should appear as follows:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh4.googleusercontent.com/-jeUAHhbAvBE/Td4xvl0L-6I/AAAAAAAAGA4/WqJAhGw93s4/s400/USAMountains08DetailViewControllerFilesOwnerConnectionsInspector.png" alt="" width="400" height="148" /><p class="wp-caption-text">Connections Inspector for File's Owner</p></div>
<p>You should be good to check this out in the Simulator. Remember you need to hold down the Option button and drag the mouse to get the multi touch over the map for zooming. Scroll the map by dragging the mouse.</p>
<p><a href="http://www.lonhosford.com/lonblog/2011/05/24/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-7-add-detail-view/">&lt;== Lesson 7</a> || <a href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/">Overview</a>  ||  <a href="http://www.lonhosford.com/lonblog/2011/05/27/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-9-add-annotation-to-mapview/">Lesson 9 ==&gt; </a</p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" send="true" width="450" show_faces="true" font=""></fb:like></p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" num_posts="2" width="500"></fb:comments></p>
<p><!-- Begin MailChimp Signup Form --><br />
<!--[if IE]></p>
<style type="text/css" media="screen">
	#mc_embed_signup fieldset {position: relative;}
	#mc_embed_signup legend {position: absolute; top: -1em; left: .2em;}
</style>
<p><![endif]--><br />
<!--[if IE 7]></p>
<style type="text/css" media="screen">
	.mc-field-group {overflow:visible;}
</style>
<p><![endif]--></p>
<div id="mc_embed_signup">
<form action="http://clicksystemsconsulting.us1.list-manage.com/subscribe/post?u=1d83b555f8b0ae0bef0eda6b7&amp;id=73cb4b1340" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" style="font: normal 100% Arial, sans-serif;font-size: 12pxpx;">
<fieldset style="-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;border: 1px solid #000000;padding-top: 1.5em;margin: .5em 0;background-color: #FFFFFF;color: #333333;text-align: left;">
<legend style="white-space: normal;text-transform: capitalize;font-weight: bold;color: #666666;background: #CCCCCC;padding: .5em 1em;border: 1px solid #000000;-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;font-size: 1.2em;"><span>Register For Updates</span></legend>
<div style="padding-left:15px"> You can opt out at anytime</div>
<div class="indicate-required" style="text-align: right;font-style: italic;overflow: hidden;color: #333333;margin: 0 9% 0 0;">* indicates required</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-EMAIL" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Email Address <strong class="note-required">*</strong><br />
</label><br />
<input type="text" value="" name="EMAIL" class="required email" id="mce-EMAIL" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-FNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">First Name </label><br />
<input type="text" value="" name="FNAME" class="" id="mce-FNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-LNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Last Name </label><br />
<input type="text" value="" name="LNAME" class="" id="mce-LNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;display: none;">
    <label class="input-group-label" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Group </label></p>
<div class="input-group" style="padding: .7em .7em .7em 0;font-size: .9em;margin: 0 0 1em 0;">
<ul style="margin: 0;padding: 0;">
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" value="1" name="group[1][1]" id="mce-group[1]-1-0" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-0" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">RVCC Course Student</label></li>
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" checked value="2" name="group[1][2]" id="mce-group[1]-1-1" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-1" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">XCode IPhone Mountains Tutorial</label></li>
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" checked value="4" name="group[1][4]" id="mce-group[1]-1-2" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-2" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">New Blog Articles</label></li>
</ul></div>
</div>
<div id="mce-responses" style="float: left;top: -1.4em;padding: 0em .5em 0em .5em;overflow: hidden;width: 90%;margin: 0 5%;clear: both;">
<div class="response" id="mce-error-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;float: left;top: -1.5em;z-index: 1;width: 80%;background: FBE3E4;color: #D12F19;"></div>
<div class="response" id="mce-success-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;float: left;top: -1.5em;z-index: 1;width: 80%;background: #E3FBE4;color: #529214;"></div>
</p></div>
<div><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn" style="clear: both;width: auto;display: block;margin: 1em 0 1em 5%;"></div>
</fieldset>
<p>	<a href="#" id="mc_embed_close" class="mc_embed_close" style="display: none;">Close</a><br />
</form>
</div>
<p><script type="text/javascript">
var fnames = new Array();var ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';
try {
    var jqueryLoaded=jQuery;
    jqueryLoaded=true;
} catch(err) {
    var jqueryLoaded=false;
}
var head= document.getElementsByTagName('head')[0];
if (!jqueryLoaded) {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js';
    head.appendChild(script);
    if (script.readyState &#038;&#038; script.onload!==null){
        script.onreadystatechange= function () {
              if (this.readyState == 'complete') mce_preload_check();
        }    
    }
}
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://downloads.mailchimp.com/js/jquery.form-n-validate.js';
head.appendChild(script);
var err_style = '';
try{
    err_style = mc_custom_error_style;
} catch(e){
    err_style = 'margin: 1em 0 0 0; padding: 1em 0.5em 0.5em 0.5em; background: FFEEEE none repeat scroll 0% 0%; font-weight: bold; float: left; z-index: 1; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: FF0000;';
}
var head= document.getElementsByTagName('head')[0];
var style= document.createElement('style');
style.type= 'text/css';
if (style.styleSheet) {
  style.styleSheet.cssText = '.mce_inline_error {' + err_style + '}';
} else {
  style.appendChild(document.createTextNode('.mce_inline_error {' + err_style + '}'));
}
head.appendChild(style);
setTimeout('mce_preload_check();', 250);</p>
<p>var mce_preload_checks = 0;
function mce_preload_check(){
    if (mce_preload_checks>40) return;
    mce_preload_checks++;
    try {
        var jqueryLoaded=jQuery;
    } catch(err) {
        setTimeout('mce_preload_check();', 250);
        return;
    }
    try {
        var validatorLoaded=jQuery("#fake-form").validate({});
    } catch(err) {
        setTimeout('mce_preload_check();', 250);
        return;
    }
    mce_init_form();
}
function mce_init_form(){
    jQuery(document).ready( function($) {
      var options = { errorClass: 'mce_inline_error', errorElement: 'div', onkeyup: function(){}, onfocusout:function(){}, onblur:function(){}  };
      var mce_validator = $("#mc-embedded-subscribe-form").validate(options);
      options = { url: 'http://clicksystemsconsulting.us1.list-manage1.com/subscribe/post-json?u=1d83b555f8b0ae0bef0eda6b7&#038;id=73cb4b1340&#038;c=?', type: 'GET', dataType: 'json', contentType: "application/json; charset=utf-8",
                    beforeSubmit: function(){
                        $('#mce_tmp_error_msg').remove();
                        $('.datefield','#mc_embed_signup').each(
                            function(){
                                var txt = 'filled';
                                var fields = new Array();
                                var i = 0;
                                $(':text', this).each(
                                    function(){
                                        fields[i] = this;
                                        i++;
                                    });
                                $(':hidden', this).each(
                                    function(){
                                    	if ( fields[0].value=='MM' &#038;&#038; fields[1].value=='DD' &#038;&#038; fields[2].value=='YYYY' ){
                                    		this.value = '';
									    } else if ( fields[0].value=='' &#038;&#038; fields[1].value=='' &#038;&#038; fields[2].value=='' ){
                                    		this.value = '';
									    } else {
	                                        this.value = fields[0].value+'/'+fields[1].value+'/'+fields[2].value;
	                                    }
                                    });
                            });
                        return mce_validator.form();
                    }, 
                    success: mce_success_cb
                };
      $('#mc-embedded-subscribe-form').ajaxForm(options);      </p>
<p>    });
}
function mce_success_cb(resp){
    $('#mce-success-response').hide();
    $('#mce-error-response').hide();
    if (resp.result=="success"){
        $('#mce-'+resp.result+'-response').show();
        $('#mce-'+resp.result+'-response').html(resp.msg);
        $('#mc-embedded-subscribe-form').each(function(){
            this.reset();
    	});
    } else {
        var index = -1;
        var msg;
        try {
            var parts = resp.msg.split(' - ',2);
            if (parts[1]==undefined){
                msg = resp.msg;
            } else {
                i = parseInt(parts[0]);
                if (i.toString() == parts[0]){
                    index = parts[0];
                    msg = parts[1];
                } else {
                    index = -1;
                    msg = resp.msg;
                }
            }
        } catch(e){
            index = -1;
            msg = resp.msg;
        }
        try{
            if (index== -1){
                $('#mce-'+resp.result+'-response').show();
                $('#mce-'+resp.result+'-response').html(msg);            
            } else {
                err_id = 'mce_tmp_error_msg';
                html = '
<div id="'+err_id+'" style="'+err_style+'"> '+msg+'</div>
<p>';</p>
<p>                var input_id = '#mc_embed_signup';
                var f = $(input_id);
                if (ftypes[index]=='address'){
                    input_id = '#mce-'+fnames[index]+'-addr1';
                    f = $(input_id).parent().parent().get(0);
                } else if (ftypes[index]=='date'){
                    input_id = '#mce-'+fnames[index]+'-month';
                    f = $(input_id).parent().parent().get(0);
                } else {
                    input_id = '#mce-'+fnames[index];
                    f = $().parent(input_id).get(0);
                }
                if (f){
                    $(f).append(html);
                    $(input_id).focus();
                } else {
                    $('#mce-'+resp.result+'-response').show();
                    $('#mce-'+resp.result+'-response').html(msg);
                }
            }
        } catch(e){
            $('#mce-'+resp.result+'-response').show();
            $('#mce-'+resp.result+'-response').html(msg);
        }
    }
}</p>
<p></script><br />
<!--End mc_embed_signup--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lonhosford.com/lonblog/2011/05/26/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-8-add-mapview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XCode 4 IPhone Mountains of the USA Tutorial: Lesson 7 &#8211; Add Detail View</title>
		<link>http://www.lonhosford.com/lonblog/2011/05/24/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-7-add-detail-view/</link>
		<comments>http://www.lonhosford.com/lonblog/2011/05/24/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-7-add-detail-view/#comments</comments>
		<pubDate>Tue, 24 May 2011 11:48:29 +0000</pubDate>
		<dc:creator>Lon Hosford</dc:creator>
				<category><![CDATA[IPhone]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.lonhosford.com/lonblog/?p=2140</guid>
		<description><![CDATA[&#60;== Lesson 6 &#124;&#124; Overview &#124;&#124; Lesson 8 ==&#62; In Lesson 5 you added touch interaction with the table view and displayed an alert popup. In this lesson you will refactor that to open a second screen in the hierarchy of the NavigationController you set up in Lesson 1. For now you can just use [...]]]></description>
				<content:encoded><![CDATA[<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" send="true" width="450" show_faces="true" font=""></fb:like><br />
<a href="http://www.lonhosford.com/lonblog/2011/05/22/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-6-add-slider-to-search-by-elevation/">&lt;== Lesson 6</a> || <a href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/">Overview</a>  || <a href="http://www.lonhosford.com/lonblog/2011/05/26/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-8-add-mapview/">Lesson 8 ==&gt; </a>   </p>
<p>In <a href="http://www.lonhosford.com/lonblog/2011/05/18/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-5-table-touch-interaction/">Lesson 5</a> you added touch interaction with the table view and displayed an alert popup.<img class="alignleft" src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/TcVF8NRLevI/AAAAAAAAF2U/dZ3fASCSYCA/s800/USAMountainsBlogImage.png" alt="" width="160" height="218" /> In this lesson you will refactor that to open a second screen in the hierarchy of the NavigationController you set up in <a href="http://www.lonhosford.com/lonblog/2011/05/11/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-1-setup-the-app/">Lesson 1</a>.</p>
<div class="wp-caption alignright" style="width: 215px"><img class=" " style="border: 0pt none;" src="https://lh4.googleusercontent.com/_e5pwU0LJbN8/Tdt5rYUDwMI/AAAAAAAAF_o/-mdzcMl_kAU/s400/USAMountains07Screen02.png" alt="" width="205" height="400" /><p class="wp-caption-text">Detail View Screen</p></div>
<p>For now you can just use a TextView to display some information about the mountain the user selected. In a later lesson you will redesign that to include a map view showing the mountain&#8217;s location.</p>
<p>You have much of the basic structure in place. For instance you need to pass mountain data to the second view. You have the MountainItem objects stored in the NSMutableArray supporting the table. So you can pass the selected table row&#8217;s MountainItem object to the detail view.</p>
<p><strong>Source Download</strong></p>
<ol>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial06.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial06.zip">Starting XCode 4 Project</a>. This is the lesson 6 project completed.</li>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial02PHP_CSV_files.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial02PHP_CSV_files.zip">PHP and CSV Files</a>. Script to read data file and selects by elevation and returns XML. <a href="http://www.lonhosford.com/lonblog/2011/05/12/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-2-load-xml-data/"> See Lesson 2</a>.</li>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial07.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial07.zip">Completed XCode 4 Project</a></li>
</ol>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p><strong>Step 1: Create The DetailViewController</strong><br />
Download and uncompress the <a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial06.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial06.zip">Starting XCode Project</a> file and open in XCode.</p>
<p>The first task is to add a controller with a view attached. </p>
<p>Select File->New File</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/Tdt-QT-k-3I/AAAAAAAAGAE/9oY6kj36TzA/s400/USAMountains07DetailViewControllerFileNew.png" alt="" width="400" height="124" /><p class="wp-caption-text">New File</p></div>
<p>Select the UIViewController subclass and select Next.</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh3.googleusercontent.com/_e5pwU0LJbN8/Tdt-QXdyGTI/AAAAAAAAGAA/n4oiby6__cU/s400/USAMountains07DetailViewControllerChooseTemplate.png" alt="" width="400" height="98" /><p class="wp-caption-text">Choose File Template</p></div>
<p>Verify that &#8220;Targeted for IPad&#8221; is unchecked and &#8220;With XIB for user interface&#8221; is checked. Then select Next.</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh3.googleusercontent.com/_e5pwU0LJbN8/Tdt-P1Gw7YI/AAAAAAAAF_4/FBcbtxtPdJU/s400/USAMountains07DetailViewControllerChooseOptions.png" alt="" width="400" height="210" /><p class="wp-caption-text">Choose Options</p></div>
<p>If you are using the starter file, then this screen should match up. All you need to do is type the file name &#8220;DetailViewController&#8221; and select Save. </p>
<div style="padding-left:20px;padding-right:20px;font-size:10px;">You have options here that are XCode related such as groups for files, the testing target and even the project to contain the file.</div>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh3.googleusercontent.com/_e5pwU0LJbN8/Tdt-PsMZjaI/AAAAAAAAF_8/57FebgHjg9E/s400/USAMountains07DetailViewControllerSaveAs_source.png" alt="" width="400" height="269" /><p class="wp-caption-text">Save File</p></div>
<p>You now have three new files you can see in the XCode Project explorer.</p>
<div class="wp-caption aligncenter" style="width: 363px"><img class=" " src="https://lh6.googleusercontent.com/_e5pwU0LJbN8/Tdt-P1y3LXI/AAAAAAAAF_0/k19CrSRymU0/s800/USAMountains07DetailViewControllerProjectExplorer.png" alt="" width="257" height="353" /><p class="wp-caption-text">DetailViewContoller Files Created</p></div>
<p><strong>Step 2: DetailViewController.h &#8211; Add TextView and MountainItem Objects</strong><br />
Open the DetailViewController.h file and add the highlighted code.</p>
<p>Lines 2, 7 and 11 include a MountainItem object to hold the data your MainViewController will pass into this class.</p>
<p>Lines 5 and 9 are a UITextView that is used to display some of the data in the MountainItem object. </p>
<pre class="brush: objc; highlight: [2,5,6,7,9,10,11]; title: ; notranslate">
#import &lt;UIKit/UIKit.h&gt;
#import &quot;MountainItem.h&quot;

@interface DetailViewController : UIViewController {
    UITextView *mountainInfoTextView;
    
    MountainItem *mountainItem;
}
@property (nonatomic, retain) IBOutlet UITextView *mountainInfoTextView;

@property (nonatomic, retain) MountainItem *mountainItem;
@end
</pre>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p><strong>Step 3: DetailViewController.m &#8211; Include TextView and MountainItem Objects</strong></p>
<p>Open the DetailViewController.m file and add the highlighted code.</p>
<p>This is the routine step to include the header file properties and to handle memory management.</p>
<pre class="brush: objc; highlight: [4,5,17,18,44]; title: ; notranslate">
#import &quot;DetailViewController.h&quot;


@implementation DetailViewController
@synthesize mountainInfoTextView;
@synthesize mountainItem;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [mountainInfoTextView dealloc];
    [mountainItem dealloc];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.mountainInfoTextView = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
</pre>
<p><strong>Step 4: DetailViewController.m &#8211; Set the DetailViewController UI Data</strong></p>
<p>This step overrides the UIViewController viewWillAppear:animated method.</p>
<p>This allows us to set the NavigationBar title and the UITextview mountainInfoTextView text property with data that you will pass from the MainViewController in a later step.</p>
<div style="padding-left:20px;padding-right:20px;font-size:10px;">The viewDidLoad method was not used because it is only called once unless the DetailViewController&#8217;s view is removed from the NavigationController navController stack of views. Thus on subsequent mountain choices the view would show the same data from the first time it was added to the NavigationController navController. The NavigationController navController is set up in the application delegate USAMountainsTutorial07AppDelegate.</div>
<p>The viewWillAppear method is called when the view needs to show on the display area.</p>
<p>Line 54 assures the superclass viewWillAppear is executed. </p>
<p>Line 55 sets the title using the MountainItem data received from the MainViewController.</p>
<p>Line 56 places some of the MountainItem data received into the UITextView mountainInfoTextView text property. Nothing fancy is needed here as this is temporary.</p>
<pre class="brush: objc; first-line: 52; highlight: [52,53,54,55,56,57,58,59]; title: ; notranslate">
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self setTitle:mountainItem.name];
     
    mountainInfoTextView.text = [NSString stringWithFormat: @&quot;Name: %@\nElevation: %f\nLatitude: %f\nLongitude: %f&quot;,mountainItem.name, [mountainItem.elevation floatValue],  [mountainItem.latitude floatValue], [mountainItem.longitude floatValue]]; 

}
@end
</pre>
<p><strong>Step 5: DetailViewController.xib &#8211; Set up the TextView and View</strong></p>
<p>Open the DetailViewController.xib in the project explorer.</p>
<p>Select the View and then the Property Inspector. Set the Top Bar property to Navigation Bar.</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh6.googleusercontent.com/_e5pwU0LJbN8/TduisEpaoGI/AAAAAAAAGAU/hJwL6WNMf6M/s400/USAMountains07DetailViewControllerViewPropertyInspector.png" alt="" width="400" height="147" /><p class="wp-caption-text">View Property Inspector</p></div>
<p>Next in the Objects panel in the lower right drag a TextView object to the View. Size it to fill the screen. </p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh6.googleusercontent.com/_e5pwU0LJbN8/TcxQ7H8t8QI/AAAAAAAAF6c/cbcpyO_KOR4/s400/XCode4_TextView.png" alt="" width="400" height="51" /><p class="wp-caption-text">TextView in Objects</p></div>
<p>This is how the design area should appear:</p>
<div class="wp-caption aligncenter" style="width: 284px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/TduisRLIf6I/AAAAAAAAGAY/SODO2zdrVL0/s400/USAMountains07DetailViewControllerXib.png" alt="" width="274" height="400" /><p class="wp-caption-text">Text View in Design Layout</p></div>
<p>With the TextView selected open the Connection Inspector. Drag a &#8220;New Referencing Outlet&#8221; to the File&#8217;s Owner icon. When you release the mouse, select mountainInfoTextView from the popup menu over the File&#8217;s Owner Icon.  Here is the result:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh4.googleusercontent.com/_e5pwU0LJbN8/TduirwI1q4I/AAAAAAAAGAQ/bgbZOk1X6lw/s400/USAMountains07DetailViewControllerTextViewConnectionsInspector.png" alt="" width="400" height="138" /><p class="wp-caption-text">Text View Connection Inspector</p></div>
<p>To check your work, keep the Connections Inspector open and select the File&#8217;s Owner icon and you should see the following:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/TduiruN7N-I/AAAAAAAAGAM/ZuJb31lQYNo/s400/USAMountains07DetailViewControllerFilesOwnerPropertyInspector.png" alt="" width="400" height="147" /><p class="wp-caption-text">File's Owner Connection Inspector</p></div>
<p><strong>Step 5: MainViewController.h &#8211; Add the DetailViewController</strong></p>
<p>Open the MainViewController.h file. </p>
<p>Update line 1 with your server URL.</p>
<p>Add the highlighted lines 4, 21 and 37.</p>
<p>These lines make a DetailViewController object for this class.</p>
<pre class="brush: objc; highlight: [1,4,21,37]; title: ; notranslate">
#define kTextURL    @&quot;http://YOUR_DOMAIN/PATH_IF_ANY_TO_SCRIPT/PHP_SCRIPT_OR_XML_FILE&quot;

#import &lt;UIKit/UIKit.h&gt;
#import &quot;DetailViewController.h&quot;

@interface MainViewController : UIViewController &lt;NSXMLParserDelegate, UITableViewDelegate, UITableViewDataSource&gt;
{
    UIButton                *searchButton;
    UIActivityIndicatorView *activityIndicator;
    UITableView             *resultsTableView;
    UILabel                 *elevationLabel;
    UISlider                *elevationSlider;
    
    NSURLConnection         *urlConnection;
    NSMutableData           *receivedData;
    
    NSXMLParser             *xmlParser;
    
    NSMutableArray          *mountainData;
    
    DetailViewController    *detailView;

}
@property (nonatomic, retain) IBOutlet UIButton                 *searchButton;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView  *activityIndicator;
@property (nonatomic, retain) IBOutlet UITableView              *resultTableView;
@property (nonatomic, retain) IBOutlet UILabel                  *elevationLabel;
@property (nonatomic, retain) IBOutlet UISlider                 *elevationSlider;

@property (nonatomic, retain) NSURLConnection *urlConnection;
@property (nonatomic, retain) NSMutableData *receivedData;

@property (nonatomic, retain) NSXMLParser *xmlParser;

@property (nonatomic, retain) NSMutableArray *mountainData;

@property (nonatomic, retain) DetailViewController *detailView;

-(IBAction) startSearch:(id)sender;
- (void) setUIState:(int)uiState;
- (IBAction)sliderChanged:(id)sender;

-(NSString *) getCommaSeparatedFromStringContainingNumber:(NSString *)stringWithNumber;
@end

</pre>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p><strong>Step 6: MainViewController.m &#8211; Include the DetailViewController Object</strong></p>
<p>Open the MainViewController.m file and add the highlighted lines.</p>
<p>These lines include the DetailViewController detailView object for this class to manage.</p>
<pre class="brush: objc; highlight: [18,45,83]; title: ; notranslate">
#import &quot;MainViewController.h&quot;
#import &quot;MountainItem.h&quot;

@implementation MainViewController
@synthesize searchButton;
@synthesize activityIndicator;
@synthesize resultTableView;
@synthesize elevationLabel;
@synthesize elevationSlider;

@synthesize urlConnection;
@synthesize receivedData;

@synthesize xmlParser;

@synthesize mountainData;

@synthesize detailView;


// State is loading data. Used to set view.
static const int LOADING_STATE = 1;
// State is active. Used to set view.
static const int ACTIVE_STATE = 0;



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [searchButton release];
    [activityIndicator release];
    [resultTableView release];
    [elevationLabel release];
    [elevationSlider release];
    [urlConnection release];
    [receivedData release];
    [xmlParser release];
    [mountainData release];
    [detailView release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    mountainData = [[NSMutableArray alloc] init];
    [mountainData retain];

    [self setTitle:@&quot;USA Mountains Lesson 7&quot;];
    UIBarButtonItem *newBarButtonItem = [[UIBarButtonItem alloc] init];
	newBarButtonItem.title = @&quot;Return&quot;;
	self.navigationItem.backBarButtonItem = newBarButtonItem;
	[newBarButtonItem release];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.searchButton = nil;
    self.activityIndicator = nil;
    self.resultTableView = nil;
    self.elevationLabel = nil;
    self.elevationSlider = nil;
    self.detailView = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

</pre>
<p>The following code does not change and is included here for online reference:</p>
<pre class="brush: objc; collapse: true; first-line: 91; light: false; title: ; toolbar: true; notranslate">
#pragma mark - UI Interface
- (IBAction)sliderChanged:(id)sender
{
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@&quot;###,##0&quot;];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithFloat:elevationSlider.value]];
    elevationLabel.text = [[NSString alloc] initWithFormat:@&quot;Elevation %@ feet&quot;,formattedNumberString];
    
    [numberFormatter release];
}
-(IBAction) startSearch:(id)sender
{
    NSLog(@&quot;startSearch&quot;);
     // Change UI to loading state
    [self setUIState:LOADING_STATE];
    // Convert the NSSlider elevationValue_ui value to a string
    NSString *elevation = [[NSString alloc ] initWithFormat:@&quot;%.0f&quot;, elevationSlider.value]; 
    // Create the URL which would be http://YOUR_DOMAIN_NAME/PATH_IF_ANY_TO/get_usa_mountain_data.php?elevation=12000
    NSString *urlAsString = [NSString stringWithFormat:
                             @&quot;%@%s%@&quot;, kTextURL , &quot;?elevation_min=&quot;, elevation];

    //NSLog(@&quot;urlAsString: %@&quot;,urlAsString );
    NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlAsString]];
    // Create the NSURLConnection con object with the NSURLRequest req object 
    // and make this MountainsEx01ViewController the delegate.
    urlConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];
    // Connection successful
    if (urlConnection) {
        NSMutableData *data = [[NSMutableData alloc] init];
        self.receivedData=data;
        [data release];
    } 
    // Bad news, connection failed.
    else 
    {
        UIAlertView *alert = [
                              [UIAlertView alloc] 
                              initWithTitle:NSLocalizedString(@&quot;Error&quot;, @&quot;Error&quot;)
                              message:NSLocalizedString(@&quot;Error connecting to remote server&quot;, @&quot;Error connecting to remote server&quot;)
                              delegate:self 
                              cancelButtonTitle:NSLocalizedString(@&quot;Bummer&quot;, @&quot;Bummer&quot;)
                              otherButtonTitles:nil
                              ];
        [alert show];
        [alert release];
    }
    [req release];
    [elevation release];
    
}
-(void) setUIState:(int)uiState;
{
    // Set view state to animating.
    if (uiState == LOADING_STATE)
    {
        searchButton.enabled = false;
        searchButton.alpha = 0.5f;
        [activityIndicator startAnimating];
        
    }
    // Set view state to not animating.
    else if (uiState == ACTIVE_STATE)
    {
        searchButton.enabled = true;
        searchButton.alpha = 1.0f;
        [activityIndicator stopAnimating];
    }
}

#pragma mark - NSURLConnection Callbacks
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response 
{
    [receivedData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 
{
    [receivedData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error 
{
    [connection release];
    self.receivedData = nil; 
    
    UIAlertView *alert = [[UIAlertView alloc] 
                          initWithTitle:@&quot;Error&quot;
                          message:[NSString stringWithFormat:@&quot;Connection failed! Error - %@ (URL: %@)&quot;, [error localizedDescription],[[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]] 
                          delegate:self
                          cancelButtonTitle:@&quot;Bummer&quot;
                          otherButtonTitles:nil];
    [alert show];
    [alert release];
    // Change UI to active state
    [self setUIState:ACTIVE_STATE];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{
    [mountainData removeAllObjects];
    // Convert receivedData to NSString.
    
    xmlParser = [[NSXMLParser alloc] initWithData:receivedData];
    [xmlParser setDelegate:self]; 
    [xmlParser parse];

    [self.resultTableView reloadData];

    // Connection resources release.
    [connection release];
    self.receivedData = nil;
    // Change UI to active state
    [self setUIState:ACTIVE_STATE];
}

#pragma mark - NSXMLParser Callbacks
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI 
 qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    //Is a mountain_item node
    if ([elementName isEqualToString:@&quot;mountain_item&quot;])
    {
        MountainItem *mountainItem = [[MountainItem alloc] init];
        mountainItem.name = [attributeDict objectForKey:@&quot;name&quot;];
        mountainItem.elevation = [attributeDict objectForKey:@&quot;elevation&quot;];
        mountainItem.elevationAsString = [self getCommaSeparatedFromStringContainingNumber:[attributeDict objectForKey:@&quot;elevation&quot;]];
        mountainItem.latitude = [attributeDict objectForKey:@&quot;lat&quot;];
        mountainItem.longitude = [attributeDict objectForKey:@&quot;lon&quot;];
        
        [mountainData addObject:mountainItem];

        [mountainItem release];
        mountainItem = nil;
        
    }
    
}
#pragma mark - Table View Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{
    return [self.mountainData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *SimpleTableIdentifier = @&quot;SimpleTableIdentifier&quot;;
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
							 SimpleTableIdentifier];
    // UITableViewCell cell needs creating for this UITableView row.
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc]
				 initWithStyle:UITableViewCellStyleDefault
				 reuseIdentifier:SimpleTableIdentifier] autorelease];
    }
    NSUInteger row = [indexPath row];
    if ([mountainData count] - 1 &gt;= row)
    {
        // Create a MountainItem object from the NSMutableArray mountainData
        MountainItem *mountainItemData = [mountainData objectAtIndex:row];
        // Compose a NSString to show UITableViewCell cell as Mountain Name - nn,nnnn 
        NSString *rowText = [[NSString alloc ] initWithFormat:@&quot;%@ - %@ feet&quot;,mountainItemData.name, mountainItemData.elevationAsString];
        // Set UITableViewCell cell
        cell.textLabel.text = rowText;
        cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
        // Release alloc vars
        [rowText release];
    }
    return cell;
}

</pre>
<p><strong>Step 7: MainViewController.m &#8211; Modify the didSelectRowAtIndexPath to Open the DetailViewController</strong></p>
<p>The lines you need to remove are highlighted here for your convenience:</p>
<pre class="brush: objc; collapse: true; first-line: 258; highlight: [265,266,267,268,269,270,271,272,273,274,275,276,277,278]; light: false; title: ; toolbar: true; notranslate">
#pragma mark - Table Delegate Methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    //NSLog(@&quot;%s&quot;, __FUNCTION__);

     
     NSUInteger row = [indexPath row];
     MountainItem *mountainItemData = [mountainData objectAtIndex:row];
     
     NSString *message = [[NSString alloc] initWithFormat:
                          @&quot;Coordinates\nLatitude: %f\nLongitude: %f&quot;, [mountainItemData.latitude floatValue], [mountainItemData.longitude floatValue]];
     UIAlertView *alert = [[UIAlertView alloc]
         initWithTitle:mountainItemData.name
         message:message
         delegate:nil
         cancelButtonTitle:@&quot;Close&quot;
         otherButtonTitles:nil];
     [alert show];
     
     [message release];
     [alert release];
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
     
}
</pre>
<p>Line 278 is optional to remove if do not want to show the selected mountain when the first screen is shown.</p>
<p>Now add the highlighted lines.</p>
<p>Lines 265 to 272 initialize the DetailViewController. Line 265 checks to see if the DetailViewController detailView object is initialized. If not, the method scoped DetailViewController detailViewTemp object is created from the DetailViewController.xib file on line 269. One line 271 detailViewTemp is set to the class  DetailViewController detailView property and then detailViewTemp is released on line 272.</p>
<p>The mountainItemData extracted from the NSMutableArray mountainData is assigned to the detailView mountainItemProperty on line 276. </p>
<p>The last line, 277, pushes the detailView into the NavigationController stack and that causes the detailView to appear. </p>
<pre class="brush: objc; first-line: 258; highlight: [265,266,267,268,269,270,271,272,273,274,275,276,277,278]; title: ; notranslate">
#pragma mark - Table Delegate Methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
     // Row number in the table.
     NSUInteger row = [indexPath row];
     // Data for that row
     MountainItem *mountainItemData = [mountainData objectAtIndex:row];
    // DetailViewController not initialized.
    if (self.detailView == nil)
    {
        // Create a temporary local method variable for DetailViewController
        DetailViewController *detailViewTemp = [[DetailViewController alloc] initWithNibName:@&quot;DetailViewController&quot; bundle:nil];
        // Assign local DetailViewController variable to class instance detailView
        self.detailView = detailViewTemp;
        [detailViewTemp release];
    }
     
    // Pass the selected data to the detailView
    detailView.mountainItem = mountainItemData;
    // Add the detailView to the navigation stack
    [self.navigationController pushViewController:detailView animated:YES];
     
}

</pre>
<p>The remainder of the MainViewController.m file is included here for online reference.</p>
<pre class="brush: objc; collapse: true; first-line: 281; light: false; title: ; toolbar: true; notranslate">
#pragma mark - Utilities
-(NSString *) getCommaSeparatedFromStringContainingNumber:(NSString *)stringWithNumber
{
    // Convert the MountainItem.elevation as a NSString to a NSNumber
    NSNumberFormatter * elevationToNumber = [[NSNumberFormatter alloc] init];
    [elevationToNumber setNumberStyle:NSNumberFormatterDecimalStyle];
    NSString *elevation = stringWithNumber;
    NSNumber *myNumber = [elevationToNumber numberFromString:elevation];
    [elevationToNumber release];
    
    // Format elevation as a NSNumber to a comma separated NSString
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@&quot;###,##0&quot;];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:myNumber];
    [numberFormatter release];
    return formattedNumberString;
}

@end
</pre>
<p>Try it out in the IPhone simulator.</p>
<p><a href="http://www.lonhosford.com/lonblog/2011/05/22/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-6-add-slider-to-search-by-elevation/">&lt;== Lesson 6</a> || <a href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/">Overview</a>  || <a href="http://www.lonhosford.com/lonblog/2011/05/26/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-8-add-mapview/">Lesson 8 ==&gt; </a> </p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" send="true" width="450" show_faces="true" font=""></fb:like></p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" num_posts="2" width="500"></fb:comments></p>
<p><!-- Begin MailChimp Signup Form --><br />
<!--[if IE]></p>
<style type="text/css" media="screen">
	#mc_embed_signup fieldset {position: relative;}
	#mc_embed_signup legend {position: absolute; top: -1em; left: .2em;}
</style>
<p><![endif]--><br />
<!--[if IE 7]></p>
<style type="text/css" media="screen">
	.mc-field-group {overflow:visible;}
</style>
<p><![endif]--></p>
<div id="mc_embed_signup">
<form action="http://clicksystemsconsulting.us1.list-manage.com/subscribe/post?u=1d83b555f8b0ae0bef0eda6b7&amp;id=73cb4b1340" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" style="font: normal 100% Arial, sans-serif;font-size: 12pxpx;">
<fieldset style="-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;border: 1px solid #000000;padding-top: 1.5em;margin: .5em 0;background-color: #FFFFFF;color: #333333;text-align: left;">
<legend style="white-space: normal;text-transform: capitalize;font-weight: bold;color: #666666;background: #CCCCCC;padding: .5em 1em;border: 1px solid #000000;-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;font-size: 1.2em;"><span>Register For Updates</span></legend>
<div style="padding-left:15px"> You can opt out at anytime</div>
<div class="indicate-required" style="text-align: right;font-style: italic;overflow: hidden;color: #333333;margin: 0 9% 0 0;">* indicates required</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-EMAIL" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Email Address <strong class="note-required">*</strong><br />
</label><br />
<input type="text" value="" name="EMAIL" class="required email" id="mce-EMAIL" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-FNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">First Name </label><br />
<input type="text" value="" name="FNAME" class="" id="mce-FNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-LNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Last Name </label><br />
<input type="text" value="" name="LNAME" class="" id="mce-LNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;display: none;">
    <label class="input-group-label" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Group </label></p>
<div class="input-group" style="padding: .7em .7em .7em 0;font-size: .9em;margin: 0 0 1em 0;">
<ul style="margin: 0;padding: 0;">
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" value="1" name="group[1][1]" id="mce-group[1]-1-0" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-0" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">RVCC Course Student</label></li>
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" checked value="2" name="group[1][2]" id="mce-group[1]-1-1" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-1" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">XCode IPhone Mountains Tutorial</label></li>
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" checked value="4" name="group[1][4]" id="mce-group[1]-1-2" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-2" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">New Blog Articles</label></li>
</ul></div>
</div>
<div id="mce-responses" style="float: left;top: -1.4em;padding: 0em .5em 0em .5em;overflow: hidden;width: 90%;margin: 0 5%;clear: both;">
<div class="response" id="mce-error-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;float: left;top: -1.5em;z-index: 1;width: 80%;background: FBE3E4;color: #D12F19;"></div>
<div class="response" id="mce-success-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;float: left;top: -1.5em;z-index: 1;width: 80%;background: #E3FBE4;color: #529214;"></div>
</p></div>
<div><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn" style="clear: both;width: auto;display: block;margin: 1em 0 1em 5%;"></div>
</fieldset>
<p>	<a href="#" id="mc_embed_close" class="mc_embed_close" style="display: none;">Close</a><br />
</form>
</div>
<p><script type="text/javascript">
var fnames = new Array();var ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';
try {
    var jqueryLoaded=jQuery;
    jqueryLoaded=true;
} catch(err) {
    var jqueryLoaded=false;
}
var head= document.getElementsByTagName('head')[0];
if (!jqueryLoaded) {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js';
    head.appendChild(script);
    if (script.readyState &#038;&#038; script.onload!==null){
        script.onreadystatechange= function () {
              if (this.readyState == 'complete') mce_preload_check();
        }    
    }
}
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://downloads.mailchimp.com/js/jquery.form-n-validate.js';
head.appendChild(script);
var err_style = '';
try{
    err_style = mc_custom_error_style;
} catch(e){
    err_style = 'margin: 1em 0 0 0; padding: 1em 0.5em 0.5em 0.5em; background: FFEEEE none repeat scroll 0% 0%; font-weight: bold; float: left; z-index: 1; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: FF0000;';
}
var head= document.getElementsByTagName('head')[0];
var style= document.createElement('style');
style.type= 'text/css';
if (style.styleSheet) {
  style.styleSheet.cssText = '.mce_inline_error {' + err_style + '}';
} else {
  style.appendChild(document.createTextNode('.mce_inline_error {' + err_style + '}'));
}
head.appendChild(style);
setTimeout('mce_preload_check();', 250);</p>
<p>var mce_preload_checks = 0;
function mce_preload_check(){
    if (mce_preload_checks>40) return;
    mce_preload_checks++;
    try {
        var jqueryLoaded=jQuery;
    } catch(err) {
        setTimeout('mce_preload_check();', 250);
        return;
    }
    try {
        var validatorLoaded=jQuery("#fake-form").validate({});
    } catch(err) {
        setTimeout('mce_preload_check();', 250);
        return;
    }
    mce_init_form();
}
function mce_init_form(){
    jQuery(document).ready( function($) {
      var options = { errorClass: 'mce_inline_error', errorElement: 'div', onkeyup: function(){}, onfocusout:function(){}, onblur:function(){}  };
      var mce_validator = $("#mc-embedded-subscribe-form").validate(options);
      options = { url: 'http://clicksystemsconsulting.us1.list-manage1.com/subscribe/post-json?u=1d83b555f8b0ae0bef0eda6b7&#038;id=73cb4b1340&#038;c=?', type: 'GET', dataType: 'json', contentType: "application/json; charset=utf-8",
                    beforeSubmit: function(){
                        $('#mce_tmp_error_msg').remove();
                        $('.datefield','#mc_embed_signup').each(
                            function(){
                                var txt = 'filled';
                                var fields = new Array();
                                var i = 0;
                                $(':text', this).each(
                                    function(){
                                        fields[i] = this;
                                        i++;
                                    });
                                $(':hidden', this).each(
                                    function(){
                                    	if ( fields[0].value=='MM' &#038;&#038; fields[1].value=='DD' &#038;&#038; fields[2].value=='YYYY' ){
                                    		this.value = '';
									    } else if ( fields[0].value=='' &#038;&#038; fields[1].value=='' &#038;&#038; fields[2].value=='' ){
                                    		this.value = '';
									    } else {
	                                        this.value = fields[0].value+'/'+fields[1].value+'/'+fields[2].value;
	                                    }
                                    });
                            });
                        return mce_validator.form();
                    }, 
                    success: mce_success_cb
                };
      $('#mc-embedded-subscribe-form').ajaxForm(options);      </p>
<p>    });
}
function mce_success_cb(resp){
    $('#mce-success-response').hide();
    $('#mce-error-response').hide();
    if (resp.result=="success"){
        $('#mce-'+resp.result+'-response').show();
        $('#mce-'+resp.result+'-response').html(resp.msg);
        $('#mc-embedded-subscribe-form').each(function(){
            this.reset();
    	});
    } else {
        var index = -1;
        var msg;
        try {
            var parts = resp.msg.split(' - ',2);
            if (parts[1]==undefined){
                msg = resp.msg;
            } else {
                i = parseInt(parts[0]);
                if (i.toString() == parts[0]){
                    index = parts[0];
                    msg = parts[1];
                } else {
                    index = -1;
                    msg = resp.msg;
                }
            }
        } catch(e){
            index = -1;
            msg = resp.msg;
        }
        try{
            if (index== -1){
                $('#mce-'+resp.result+'-response').show();
                $('#mce-'+resp.result+'-response').html(msg);            
            } else {
                err_id = 'mce_tmp_error_msg';
                html = '
<div id="'+err_id+'" style="'+err_style+'"> '+msg+'</div>
<p>';</p>
<p>                var input_id = '#mc_embed_signup';
                var f = $(input_id);
                if (ftypes[index]=='address'){
                    input_id = '#mce-'+fnames[index]+'-addr1';
                    f = $(input_id).parent().parent().get(0);
                } else if (ftypes[index]=='date'){
                    input_id = '#mce-'+fnames[index]+'-month';
                    f = $(input_id).parent().parent().get(0);
                } else {
                    input_id = '#mce-'+fnames[index];
                    f = $().parent(input_id).get(0);
                }
                if (f){
                    $(f).append(html);
                    $(input_id).focus();
                } else {
                    $('#mce-'+resp.result+'-response').show();
                    $('#mce-'+resp.result+'-response').html(msg);
                }
            }
        } catch(e){
            $('#mce-'+resp.result+'-response').show();
            $('#mce-'+resp.result+'-response').html(msg);
        }
    }
}</p>
<p></script><br />
<!--End mc_embed_signup--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lonhosford.com/lonblog/2011/05/24/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-7-add-detail-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XCode 4 IPhone Mountains of the USA Tutorial: Lesson 6 &#8211; Add Slider to Search By Elevation</title>
		<link>http://www.lonhosford.com/lonblog/2011/05/22/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-6-add-slider-to-search-by-elevation/</link>
		<comments>http://www.lonhosford.com/lonblog/2011/05/22/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-6-add-slider-to-search-by-elevation/#comments</comments>
		<pubDate>Sun, 22 May 2011 21:07:31 +0000</pubDate>
		<dc:creator>Lon Hosford</dc:creator>
				<category><![CDATA[IPhone]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[XCode]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.lonhosford.com/lonblog/?p=2098</guid>
		<description><![CDATA[&#60;== Lesson 5 &#124;&#124; Overview &#124;&#124; Lesson 7 ==&#62; This lesson takes advantage of the server script to select mountains based on their elevation.The script returns mountains that exceed an elevation value you provide as part of the URL request made to the web server. This means you cannot use a static XML file for [...]]]></description>
				<content:encoded><![CDATA[<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" send="true" width="450" show_faces="true" font=""></fb:like><br />
<a href="http://www.lonhosford.com/lonblog/2011/05/18/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-5-table-touch-interaction/">&lt;== Lesson 5</a> || <a href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/">Overview</a>    || <a href="http://www.lonhosford.com/lonblog/2011/05/24/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-7-add-detail-view/">Lesson 7 ==&gt; </a>   </p>
<p>This lesson takes advantage of the server script to select mountains based on their elevation.<img class="alignleft" src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/TcVF8NRLevI/AAAAAAAAF2U/dZ3fASCSYCA/s800/USAMountainsBlogImage.png" alt="" width="160" height="218" />The script returns mountains that exceed an elevation value you provide as part of the URL request made to the web server.  </p>
<div class="wp-caption alignright" style="width: 215px"><img class=" " style="border: 0pt none;" src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/TdkLGw_kabI/AAAAAAAAF-c/rmEUBogtXhM/s400/USAMountains06Screen01.png" alt="" width="205" height="400" /><p class="wp-caption-text">Slider Search By Elevation</p></div>
<p>This means you cannot use a static XML file for the UI and code that is added in this section. If you cannot provide a server, you could proceed by skipping this lesson and ignoring the code and UI added. But the code and UI will appear in all future lessons and may serve to confuse you. Best approach is to put the provided PHP script and data file in a folder on a web server and continue with these. These files are included as a part of all the lesson downloads since lesson 2.</p>
<p>The tasks in this lesson are more in adding the UI to provide the user with suitable information to understand what to do with very little screen space. This example choose to use a bit more screen space to help make the selection of an elevation more informative. </p>
<p><strong>Source Download</strong></p>
<ol>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial05.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial05.zip">Starting XCode 4 Project</a>. This is the lesson 5 project completed.</li>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial02PHP_CSV_files.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial02PHP_CSV_files.zip">PHP and CSV Files</a>. Script to read data file and selects by elevation and returns XML. <a href="http://www.lonhosford.com/lonblog/2011/05/12/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-2-load-xml-data/"> See Lesson 2</a>.</li>
<li>
<a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial06.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial06.zip">Completed XCode 4 Project</a></li>
</ol>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><br />
<strong>Step 1:  MainViewController.h &#8211; Add the Slider and Slider Label</strong></p>
<p>Download and uncompress the <a onclick="javascript: pageTracker._trackPageview('/downloads/xcode/USAMountainsTutorial05.zip'); " href="http://www.lonhosford.com/content/xcode/iphone/USAMountainsTutorial05.zip">Starting XCode Project</a> file and open in XCode.</p>
<p>Open the MainViewController.h in the project navigator window. </p>
<p>Lines 13 and 27 are the UILabel that will appear above the slider. The label shows the value in the slider. You will change the label as the slider is changed.</p>
<p>Lines 14 and 28 are the UISlider.</p>
<p>Line 39 is a IBAction method you link up in the UI to receive messages when the slider is changed. </p>
<p>Remember to change line 4 to include your url.</p>
<pre class="brush: objc; highlight: [4,13,14,27,28,39]; title: ; notranslate">
//
//
//
#define kTextURL    @&quot;http://YOUR_DOMAIN/PATH_IF_ANY_TO_SCRIPT/PHP_SCRIPT_OR_XML_FILE&quot;

#import &lt;UIKit/UIKit.h&gt;


@interface MainViewController : UIViewController &lt;NSXMLParserDelegate, UITableViewDelegate, UITableViewDataSource&gt;
{
    UIButton                *searchButton;
    UIActivityIndicatorView *activityIndicator;
    UITableView             *resultsTableView;
    UILabel                 *elevationLabel;
    UISlider                *elevationSlider;
    
    NSURLConnection         *urlConnection;
    NSMutableData           *receivedData;
    
    NSXMLParser             *xmlParser;
    
    NSMutableArray          *mountainData;

}
@property (nonatomic, retain) IBOutlet UIButton                 *searchButton;
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView  *activityIndicator;
@property (nonatomic, retain) IBOutlet UITableView              *resultTableView;
@property (nonatomic, retain) IBOutlet UILabel                  *elevationLabel;
@property (nonatomic, retain) IBOutlet UISlider                 *elevationSlider;

@property (nonatomic, retain) NSURLConnection *urlConnection;
@property (nonatomic, retain) NSMutableData *receivedData;

@property (nonatomic, retain) NSXMLParser *xmlParser;

@property (nonatomic, retain) NSMutableArray *mountainData;

-(IBAction) startSearch:(id)sender;
- (void) setUIState:(int)uiState;
- (IBAction)sliderChanged:(id)sender;

-(NSString *) getCommaSeparatedFromStringContainingNumber:(NSString *)stringWithNumber;
@end
</pre>
<p><strong>Step 2:  MainViewController.m &#8211; Add the Slider, Slider Label and Change Navbar Title</strong><br />
Open the MainViewController.m file in the project explorer.</p>
<p>This step is pretty routine.</p>
<p>You need to add in the new UI variables shown on the highlighted lines 11, 12, 40, 41, 77 and 78. These include them in the class and also take care of memory management.</p>
<p>Line 66 is the NavigationBar title you can change.</p>
<pre class="brush: objc; highlight: [11,12,40,41,66,77,78]; title: ; notranslate">
//
//
//
#import &quot;MainViewController.h&quot;
#import &quot;MountainItem.h&quot;

@implementation MainViewController
@synthesize searchButton;
@synthesize activityIndicator;
@synthesize resultTableView;
@synthesize elevationLabel;
@synthesize elevationSlider;

@synthesize urlConnection;
@synthesize receivedData;

@synthesize xmlParser;

@synthesize mountainData;

// State is loading data. Used to set view.
static const int LOADING_STATE = 1;
// State is active. Used to set view.
static const int ACTIVE_STATE = 0;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [searchButton release];
    [activityIndicator release];
    [resultTableView release];
    [elevationLabel release];
    [elevationSlider release];
    [urlConnection release];
    [receivedData release];
    [xmlParser release];
    [mountainData release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    mountainData = [[NSMutableArray alloc] init];
    [mountainData retain];

    [self setTitle:@&quot;USA Mountains Lesson 6&quot;];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.searchButton = nil;
    self.activityIndicator = nil;
    self.resultTableView = nil;
    self.elevationLabel = nil;
    self.elevationSlider = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
</pre>
<p><strong>Step 3:  MainViewController.m &#8211; Add the sliderChanged Method.</strong></p>
<p>Add all the code below  in the UI Interface section just before the <code>-(IBAction) startSearch:(id)sender</code> method.</p>
<p>When the user changes the slider, you are updating a label that shows the slider value with a comma separated number. For example <code>Elevation 10,000 feet</code>.</p>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>You can see at the end of line 91 the NSNumber value property provided by the UISlider: <code>elevationSlider.value</code>.  Lines 89 to 91 converting that to a NSString formatted with commas to create NSString *formattedNumberString.</p>
<p>Line 92 assembles NSString *formattedNumberString with the words Elevation and feet and updates the UILabel elevationLabel text property.  </p>
<p>You end with the cleanup of the NSNumberFormatter used in the process.</p>
<pre class="brush: objc; first-line: 86; highlight: [87,88,89,90,91,92,93,94]; title: ; notranslate">
#pragma mark - UI Interface
- (IBAction)sliderChanged:(id)sender
{
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@&quot;###,##0&quot;];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithFloat:elevationSlider.value]];
    elevationLabel.text = [[NSString alloc] initWithFormat:@&quot;Elevation %@ feet&quot;,formattedNumberString];
    [numberFormatter release];
}
</pre>
<p><strong>Step 4:  MainViewController.m &#8211; Modify the URL to Send the Elevation</strong></p>
<p>You need to add a URL query for example: <code>?elevation_min=10000</code>. This is needed for the PHP script. You do not need to know how to program PHP but it is included here for reference with a few key lines highlighted to illustrate.</p>
<pre class="brush: php; collapse: true; highlight: [14,16]; light: false; title: ; toolbar: true; notranslate">
&lt;?php
header(&quot;Expires: Mon, 26 Jul 1997 05:00:00 GMT&quot; );
header(&quot;Last-Modified: &quot; . gmdate( &quot;D, d M Y H:i:s&quot; ) . &quot;GMT&quot; );
header(&quot;Cache-Control: no-cache, must-revalidate&quot; );
header(&quot;Pragma: no-cache&quot; );
header(&quot;Content-Type: text/xml; charset=utf-8&quot;);
// XML to return.
$xml = '';
// Counter for number of mountains returned.
$mountain_count = 0;
// Filter mountains equal to or above this value. 
$elevation_min = 12000;
// Check for elevation parameter as a integer.
if ($_REQUEST['elevation_min'] &amp;&amp; intval($_REQUEST['elevation_min']))
{
	$elevation_min = intval( $_REQUEST['elevation_min']);
}
// Each element contains data for one mountain.
$mountains = array();
// Read a CVS file containing mountain data.
$mountain_data_lines = file('mountain_data.csv');
// Each line read .
foreach($mountain_data_lines as $line) 
{
	// Strip newline at end of line and break line by comma delimiter and 
	// append to $mountains.
	$mountains[] = explode( ',', rtrim($line));
}
// Each mountain.
foreach ($mountains as $value)
{
	// Mountain elevation equals or exceeds the filter value.
	if ( intval($value[1]) &gt;= $elevation_min  )
	{
		$mountain_count++;
		// Create the mountain_item node.
		$xml .= '&lt;mountain_item ';
		$xml .= 'id = &quot;' . $mountain_count . '&quot; ';
		$xml .= 'name = &quot;' . $value[0] . '&quot; ';
		$xml .= 'elevation = &quot;' . $value[1] . '&quot; ';
		$xml .= 'lat = &quot;' . $value[2] . '&quot; ';
		$xml .= 'lon = &quot;' . $value[3] . '&quot; ';
		$xml .= '/&gt;';

	}
}
// Add mountains close node.
$xml .= '&lt;/mountains&gt;';
// Create mountains open node.
$xml_mountains = '&lt;mountains ';
$xml_mountains .= 'source = &quot;http://en.wikipedia.org/wiki/Table_of_the_highest_major_summits_of_the_United_States&quot; ' ;
$xml_mountains .= 'elevation_min = &quot;' . $elevation_min . '&quot; ';
$xml_mountains .= 'count = &quot;' . $mountain_count . '&quot; ';
$xml_mountains .= '&gt;';
// Add mountains open node.
$xml = $xml_mountains . $xml;
// Return xml
echo $xml;
?&gt;
</pre>
<p>The PHP script provided looks for the elevation_min parameter on lines 14 and 16, absorbs it to the  $elevation_min variable and uses $elevation_min on line 33 to filter the returned mountains that have an elevation at or above that value.</p>
<p>A slight modification to the MainViewController.m startSearch method will send the elevation_min parameter to the PHP script.</p>
<p>Line 102 is added to take the slider value and convert to a number.</p>
<p>The single line of code shown on 104 and 105 adds the URL query needed by the PHP script.  </p>
<pre class="brush: objc; first-line: 95; highlight: [102,104,105]; title: ; notranslate">
-(IBAction) startSearch:(id)sender
{
    //NSLog(@&quot;startSearch&quot;);
    
     // Change UI to loading state
    [self setUIState:LOADING_STATE];
    // Convert the NSSlider elevationValue_ui value to a string
    NSString *elevation = [[NSString alloc ] initWithFormat:@&quot;%.0f&quot;, elevationSlider.value]; 
    // Create the URL which would be http://YOUR_DOMAIN_NAME/PATH_IF_ANY_TO/get_usa_mountain_data.php?elevation=12000
    NSString *urlAsString = [NSString stringWithFormat:
                             @&quot;%@%s%@&quot;, kTextURL , &quot;?elevation_min=&quot;, elevation];

    //NSLog(@&quot;urlAsString: %@&quot;,urlAsString );
    NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlAsString]];
    // Create the NSURLConnection con object with the NSURLRequest req object 
    // and make this MountainsEx01ViewController the delegate.
    urlConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];
    // Connection successful
    if (urlConnection) {
        NSMutableData *data = [[NSMutableData alloc] init];
        self.receivedData=data;
        [data release];
    } 
    // Bad news, connection failed.
    else 
    {
        UIAlertView *alert = [
                              [UIAlertView alloc] 
                              initWithTitle:NSLocalizedString(@&quot;Error&quot;, @&quot;Error&quot;)
                              message:NSLocalizedString(@&quot;Error connecting to remote server&quot;, @&quot;Error connecting to remote server&quot;)
                              delegate:self 
                              cancelButtonTitle:NSLocalizedString(@&quot;Bummer&quot;, @&quot;Bummer&quot;)
                              otherButtonTitles:nil
                              ];
        [alert show];
        [alert release];
    }
    [req release];
    [elevation release];
}
</pre>
<p>The remainder of the code is unchanged and is included here for reference:</p>
<pre class="brush: objc; collapse: true; first-line: 136; light: false; title: ; toolbar: true; notranslate">
-(void) setUIState:(int)uiState;
{
    // Set view state to animating.
    if (uiState == LOADING_STATE)
    {
        searchButton.enabled = false;
        searchButton.alpha = 0.5f;
        [activityIndicator startAnimating];
        
    }
    // Set view state to not animating.
    else if (uiState == ACTIVE_STATE)
    {
        searchButton.enabled = true;
        searchButton.alpha = 1.0f;
        [activityIndicator stopAnimating];
    }
}

#pragma mark - NSURLConnection Callbacks
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response 
{
    [receivedData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 
{
    [receivedData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error 
{
    [connection release];
    self.receivedData = nil; 
    
    UIAlertView *alert = [[UIAlertView alloc] 
                          initWithTitle:@&quot;Error&quot;
                          message:[NSString stringWithFormat:@&quot;Connection failed! Error - %@ (URL: %@)&quot;, [error localizedDescription],[[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]] 
                          delegate:self
                          cancelButtonTitle:@&quot;Bummer&quot;
                          otherButtonTitles:nil];
    [alert show];
    [alert release];
    // Change UI to active state
    [self setUIState:ACTIVE_STATE];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{
    [mountainData removeAllObjects];
    // Convert receivedData to NSString.
    
    xmlParser = [[NSXMLParser alloc] initWithData:receivedData];
    [xmlParser setDelegate:self]; 
    [xmlParser parse];

    [self.resultTableView reloadData];

    // Connection resources release.
    [connection release];
    self.receivedData = nil;
    // Change UI to active state
    [self setUIState:ACTIVE_STATE];
}

#pragma mark - NSXMLParser Callbacks
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI 
 qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    //Is a mountain_item node
    if ([elementName isEqualToString:@&quot;mountain_item&quot;])
    {
        MountainItem *mountainItem = [[MountainItem alloc] init];
        mountainItem.name = [attributeDict objectForKey:@&quot;name&quot;];
        mountainItem.elevation = [attributeDict objectForKey:@&quot;elevation&quot;];
        mountainItem.elevationAsString = [self getCommaSeparatedFromStringContainingNumber:[attributeDict objectForKey:@&quot;elevation&quot;]];
        mountainItem.latitude = [attributeDict objectForKey:@&quot;lat&quot;];
        mountainItem.longitude = [attributeDict objectForKey:@&quot;lon&quot;];
        
        [mountainData addObject:mountainItem];

        [mountainItem release];
        mountainItem = nil;
        
    }
    
}
#pragma mark - Table View Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{
    return [self.mountainData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *SimpleTableIdentifier = @&quot;SimpleTableIdentifier&quot;;
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
							 SimpleTableIdentifier];
    // UITableViewCell cell needs creating for this UITableView row.
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc]
				 initWithStyle:UITableViewCellStyleDefault
				 reuseIdentifier:SimpleTableIdentifier] autorelease];
    }
    NSUInteger row = [indexPath row];
    if ([mountainData count] - 1 &gt;= row)
    {
        // Create a MountainItem object from the NSMutableArray mountainData
        MountainItem *mountainItemData = [mountainData objectAtIndex:row];
        // Compose a NSString to show UITableViewCell cell as Mountain Name - nn,nnnn 
        NSString *rowText = [[NSString alloc ] initWithFormat:@&quot;%@ - %@ feet&quot;,mountainItemData.name, mountainItemData.elevationAsString];
        // Set UITableViewCell cell
        cell.textLabel.text = rowText;
        cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
        // Release alloc vars
        [rowText release];
    }
    return cell;
}
#pragma mark - Table Delegate Methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
    //NSLog(@&quot;%s&quot;, __FUNCTION__);

     
     NSUInteger row = [indexPath row];
     MountainItem *mountainItemData = [mountainData objectAtIndex:row];
     
     NSString *message = [[NSString alloc] initWithFormat:
                          @&quot;Coordinates\nLatitude: %f\nLongitude: %f&quot;, [mountainItemData.latitude floatValue], [mountainItemData.longitude floatValue]];
     UIAlertView *alert = [[UIAlertView alloc]
         initWithTitle:mountainItemData.name
         message:message
         delegate:nil
         cancelButtonTitle:@&quot;Close&quot;
         otherButtonTitles:nil];
     [alert show];
     
     [message release];
     [alert release];
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
     
}
#pragma mark - Utilities
-(NSString *) getCommaSeparatedFromStringContainingNumber:(NSString *)stringWithNumber
{
    // Convert the MountainItem.elevation as a NSString to a NSNumber
    NSNumberFormatter * elevationToNumber = [[NSNumberFormatter alloc] init];
    [elevationToNumber setNumberStyle:NSNumberFormatterDecimalStyle];
    NSString *elevation = stringWithNumber;
    NSNumber *myNumber = [elevationToNumber numberFromString:elevation];
    [elevationToNumber release];
    
    // Format elevation as a NSNumber to a comma separated NSString
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@&quot;###,##0&quot;];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:myNumber];
    [numberFormatter release];
    return formattedNumberString;
}

@end
</pre>
<p><strong>Step 5:  MainViewController.xib &#8211; Add in the UISlider</strong></p>
<p>Now you can move on to the UI. Refer to the screen shot at the top of the post to keep you on track with the goal of the changes.</p>
<div style = "padding-left:20px;padding-right:20px">Keep in mind, you can do this generally after you have the header definitions in place. You need those so that the Interface Builder part of XCode can display the names of methods and UI components you choose in code. These lessons choose to complete the implementation in the code before moving to UI just to keep the zig zag back and forth that XCode often creates for tutorials. As you get faster, you might want to do the UI right after you do the header files.</div>
<p>Drag a Slider from the Objects library in the bottom right to place it above the Search button.</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh6.googleusercontent.com/_e5pwU0LJbN8/TdkwUfx3PjI/AAAAAAAAF-w/-dcxnCREoTk/s400/XCode4_Slider.png" alt="" width="400" height="51" /><p class="wp-caption-text">Slider</p></div>
<p>Fine tune the position and size to match the tutorial:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/TdkwUDPvU3I/AAAAAAAAF-o/fxP0CTYGLQs/s400/USAMountainTutorial06MainViewControllerSlideSizeInspector.png" alt="" width="400" height="150" /><p class="wp-caption-text">Slider Size Inspector</p></div>
<p>Then you need to wire the MainViewController to the UISlider elevationSlider property defined in step 1 for the MainViewController header and you need to wire the UISlider valueChanged send event to the sliderChanged method you also defined in step 1.</p>
<p><div style = "text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-8926707286265620";
/* 300x250, created 7/29/10 */
google_ad_slot = "4548376258";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></p>
<p>You can use the Properties Inspector to get this done. With the Slider you placed in the design window selected open the Property Inspector. Drag from the &#8220;Value Changed&#8221; Send Event to the File&#8217;s Owner and when you release you can select the sliderChanged in the popped menu above the File&#8217;s Owner. </p>
<p>Repeat for the &#8220;New Referencing Outlet&#8221; and when you release the mouse over the File&#8217;s Owner icon select elevationSlider.</p>
<div style = "padding-left:20px;padding-right:20px">Another process you see is to control drag from the Slider in the design window to the File&#8217;s Owner in the Related Files panel on left and release mouse. You should see sliderChanged appear in a small menu popped over the File&#8217;s Owner. Click and select. Then you can repeat the process in the opposite direction and when you release over the Slider, you should see elevationSlider as a menu choice in the popped menu above the Slider. </div>
<p>The end result is shown here:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh4.googleusercontent.com/_e5pwU0LJbN8/TdkwUSN1UOI/AAAAAAAAF-s/88XLYVVCr9k/s400/USAMountainTutorial06MainViewControllerSlideConnectionsInspector.png" alt="" width="400" height="296" /><p class="wp-caption-text">Slider Connections Inspector</p></div>
<p>There are some tweaks needed to make the slider provide the range of elevations and a starting elevation. The range is to match the data available and a starting value to avoid automatic downloads of all the data every time. </p>
<p>So modify the Slider&#8217;s Property Inspector as follows:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh4.googleusercontent.com/_e5pwU0LJbN8/TdkwUAfGcjI/AAAAAAAAF-k/QdgQqmhKVsA/s400/USAMountainTutorial06MainViewControllerSlidePropertyInspector.png" alt="" width="400" height="190" /><p class="wp-caption-text">Slider Property Inspector</p></div>
<p><strong>Step 6:  MainViewController.xib &#8211; Add in the UILabel Displaying the Slider Value</strong></p>
<p>Next is a Label above the Slider to show the value of the Slider when it changes.</p>
<p>Drag a Label from the Objects library in the bottom right to place it above the Slider.</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/Tdk3HOrPEZI/AAAAAAAAF_E/mV5PVPBzbK0/s400/XCode4_Label.png" alt="" width="400" height="51" /><p class="wp-caption-text">Slider</p></div>
<p>Fine tune the position and size to match the tutorial:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh6.googleusercontent.com/_e5pwU0LJbN8/Tdk3GwfpD1I/AAAAAAAAF-8/8cWRqdDvEiU/s400/USAMountainTutorial06MainViewControllerElevationLabelSizeInspector.png" alt="" width="400" height="150" /><p class="wp-caption-text">Slider Size Inspector</p></div>
<p>Set the properties. Note the hard coded match up to display the starting value in the slider.</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/Tdk3G7aAjZI/AAAAAAAAF-4/u0QCewGtlHc/s400/USAMountainTutorial06MainViewControllerElevationLabelPropertyInspector.png" alt="" width="400" height="213" /><p class="wp-caption-text">Slider Property Inspector</p></div>
<p>Finally you got to wire this label so you can update it in the code. In code you are using the elevationLabel property defined in step 1. Open the Connections Inspector with this Label selected. Drag the New Referencing Outlet to the File&#8217;s Owner and after you release the mouse select elevationLabel in the menu popped over the File&#8217;s Owner.</p>
<p>Here is the result:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh6.googleusercontent.com/_e5pwU0LJbN8/Tdk3G10VbtI/AAAAAAAAF_A/HgDDiVikD7I/s400/USAMountainTutorial06MainViewControllerElevationLabelConnectionsInspector.png" alt="" width="400" height="110" /><p class="wp-caption-text">Slider Connections Inspector</p></div>
<p><strong>Step 7:  MainViewController.xib &#8211; Add the Minimum and Maximum Labels</strong></p>
<p>This step you add a Label on the left and a Label on the right of the Slider to give the range of elevation values possible. These Labels are static and do not need to be wired to the code.</p>
<p>Drag a Label to the <strong>left </strong>side of the Slider in the design window:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/Tdk3HOrPEZI/AAAAAAAAF_E/mV5PVPBzbK0/s400/XCode4_Label.png" alt="" width="400" height="51" /><p class="wp-caption-text">Left Slider Label</p></div>
<p>Tweak size and position as follows:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/Tdk5raCuvBI/AAAAAAAAF_Q/EFZm9_LdhO4/s400/USAMountainTutorial06MainViewControllerElevationLeftLabelSizeInspector.png" alt="" width="400" height="150" /><p class="wp-caption-text">Left Slider Label Property Inspector</p></div>
<p>The text property for this Label is 12,000 ft. You need to tweak the font size to make the text fit.</p>
<p>The properties as set:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/Tdk5rX_y4zI/AAAAAAAAF_U/HXhuPO950qQ/s400/USAMountainTutorial06MainViewControllerElevationLeftLabelPropertyInspector.png" alt="" width="400" height="213" /><p class="wp-caption-text">Left Slider Label Size Inspector</p></div>
<p>Drag a Label to the <strong>right</strong> side of the Slider in the design window:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh5.googleusercontent.com/_e5pwU0LJbN8/Tdk3HOrPEZI/AAAAAAAAF_E/mV5PVPBzbK0/s400/XCode4_Label.png" alt="" width="400" height="51" /><p class="wp-caption-text">Right Slider Label</p></div>
<p>Tweak size and position as follows:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src="https://lh6.googleusercontent.com/_e5pwU0LJbN8/Tdk5ri_CreI/AAAAAAAAF_Y/_7bMWyhfU_0/s400/USAMountainTutorial06MainViewControllerElevationRightLabelSizeInspector.png" alt="" width="400" height="150" /><p class="wp-caption-text">Right Slider Label Property Inspector</p></div>
<p>The text property for this Label is 12,000 ft. You need to tweak the font size to make the text fit.</p>
<p>The properties as set:</p>
<div class="wp-caption aligncenter" style="width: 410px"><img class=" " src=" https://lh3.googleusercontent.com/_e5pwU0LJbN8/Tdk5rd006JI/AAAAAAAAF_M/UgM4DGyzbGU/s400/USAMountainTutorial06MainViewControllerElevationRightLabelPropertyInspector.png" alt="" width="400" height="213" /><p class="wp-caption-text">Right Slider Label Size Inspector</p></div>
<p>Now try it out in the Simulator.</p>
<p><a href="http://www.lonhosford.com/lonblog/2011/05/18/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-5-table-touch-interaction/">&lt;== Lesson 5</a> || <a href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/">Overview</a>   || <a href="http://www.lonhosford.com/lonblog/2011/05/24/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-7-add-detail-view/">Lesson 7 ==&gt; </a> </p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#appId=105467682877384&amp;xfbml=1"></script><fb:like href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" send="true" width="450" show_faces="true" font=""></fb:like></p>
<div id="fb-root"></div>
<p><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="http://www.lonhosford.com/lonblog/2011/05/08/xcode-4-iphone-tutorial-mountains-of-the-usa-overview/" num_posts="2" width="500"></fb:comments></p>
<p><!-- Begin MailChimp Signup Form --><br />
<!--[if IE]></p>
<style type="text/css" media="screen">
	#mc_embed_signup fieldset {position: relative;}
	#mc_embed_signup legend {position: absolute; top: -1em; left: .2em;}
</style>
<p><![endif]--><br />
<!--[if IE 7]></p>
<style type="text/css" media="screen">
	.mc-field-group {overflow:visible;}
</style>
<p><![endif]--></p>
<div id="mc_embed_signup">
<form action="http://clicksystemsconsulting.us1.list-manage.com/subscribe/post?u=1d83b555f8b0ae0bef0eda6b7&amp;id=73cb4b1340" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" style="font: normal 100% Arial, sans-serif;font-size: 12pxpx;">
<fieldset style="-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;border: 1px solid #000000;padding-top: 1.5em;margin: .5em 0;background-color: #FFFFFF;color: #333333;text-align: left;">
<legend style="white-space: normal;text-transform: capitalize;font-weight: bold;color: #666666;background: #CCCCCC;padding: .5em 1em;border: 1px solid #000000;-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;font-size: 1.2em;"><span>Register For Updates</span></legend>
<div style="padding-left:15px"> You can opt out at anytime</div>
<div class="indicate-required" style="text-align: right;font-style: italic;overflow: hidden;color: #333333;margin: 0 9% 0 0;">* indicates required</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-EMAIL" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Email Address <strong class="note-required">*</strong><br />
</label><br />
<input type="text" value="" name="EMAIL" class="required email" id="mce-EMAIL" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-FNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">First Name </label><br />
<input type="text" value="" name="FNAME" class="" id="mce-FNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;">
<label for="mce-LNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Last Name </label><br />
<input type="text" value="" name="LNAME" class="" id="mce-LNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 90%;float: left;z-index: 999;">
</div>
<div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;display: none;">
    <label class="input-group-label" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Group </label></p>
<div class="input-group" style="padding: .7em .7em .7em 0;font-size: .9em;margin: 0 0 1em 0;">
<ul style="margin: 0;padding: 0;">
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" value="1" name="group[1][1]" id="mce-group[1]-1-0" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-0" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">RVCC Course Student</label></li>
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" checked value="2" name="group[1][2]" id="mce-group[1]-1-1" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-1" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">XCode IPhone Mountains Tutorial</label></li>
<li style="list-style: none;overflow: hidden;padding: .2em 0;clear: left;display: block;margin: 0;"><input type="checkbox" checked value="4" name="group[1][4]" id="mce-group[1]-1-2" style="margin-right: 2%;padding: .2em .3em;width: auto;float: left;z-index: 999;"><label for="mce-group[1]-1-2" style="display: block;margin: .4em 0 0 0;line-height: 1em;font-weight: bold;width: auto;float: left;text-align: left !important;">New Blog Articles</label></li>
</ul></div>
</div>
<div id="mce-responses" style="float: left;top: -1.4em;padding: 0em .5em 0em .5em;overflow: hidden;width: 90%;margin: 0 5%;clear: both;">
<div class="response" id="mce-error-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;float: left;top: -1.5em;z-index: 1;width: 80%;background: FBE3E4;color: #D12F19;"></div>
<div class="response" id="mce-success-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;float: left;top: -1.5em;z-index: 1;width: 80%;background: #E3FBE4;color: #529214;"></div>
</p></div>
<div><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn" style="clear: both;width: auto;display: block;margin: 1em 0 1em 5%;"></div>
</fieldset>
<p>	<a href="#" id="mc_embed_close" class="mc_embed_close" style="display: none;">Close</a><br />
</form>
</div>
<p><script type="text/javascript">
var fnames = new Array();var ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';
try {
    var jqueryLoaded=jQuery;
    jqueryLoaded=true;
} catch(err) {
    var jqueryLoaded=false;
}
var head= document.getElementsByTagName('head')[0];
if (!jqueryLoaded) {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js';
    head.appendChild(script);
    if (script.readyState &#038;&#038; script.onload!==null){
        script.onreadystatechange= function () {
              if (this.readyState == 'complete') mce_preload_check();
        }    
    }
}
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://downloads.mailchimp.com/js/jquery.form-n-validate.js';
head.appendChild(script);
var err_style = '';
try{
    err_style = mc_custom_error_style;
} catch(e){
    err_style = 'margin: 1em 0 0 0; padding: 1em 0.5em 0.5em 0.5em; background: FFEEEE none repeat scroll 0% 0%; font-weight: bold; float: left; z-index: 1; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: FF0000;';
}
var head= document.getElementsByTagName('head')[0];
var style= document.createElement('style');
style.type= 'text/css';
if (style.styleSheet) {
  style.styleSheet.cssText = '.mce_inline_error {' + err_style + '}';
} else {
  style.appendChild(document.createTextNode('.mce_inline_error {' + err_style + '}'));
}
head.appendChild(style);
setTimeout('mce_preload_check();', 250);</p>
<p>var mce_preload_checks = 0;
function mce_preload_check(){
    if (mce_preload_checks>40) return;
    mce_preload_checks++;
    try {
        var jqueryLoaded=jQuery;
    } catch(err) {
        setTimeout('mce_preload_check();', 250);
        return;
    }
    try {
        var validatorLoaded=jQuery("#fake-form").validate({});
    } catch(err) {
        setTimeout('mce_preload_check();', 250);
        return;
    }
    mce_init_form();
}
function mce_init_form(){
    jQuery(document).ready( function($) {
      var options = { errorClass: 'mce_inline_error', errorElement: 'div', onkeyup: function(){}, onfocusout:function(){}, onblur:function(){}  };
      var mce_validator = $("#mc-embedded-subscribe-form").validate(options);
      options = { url: 'http://clicksystemsconsulting.us1.list-manage1.com/subscribe/post-json?u=1d83b555f8b0ae0bef0eda6b7&#038;id=73cb4b1340&#038;c=?', type: 'GET', dataType: 'json', contentType: "application/json; charset=utf-8",
                    beforeSubmit: function(){
                        $('#mce_tmp_error_msg').remove();
                        $('.datefield','#mc_embed_signup').each(
                            function(){
                                var txt = 'filled';
                                var fields = new Array();
                                var i = 0;
                                $(':text', this).each(
                                    function(){
                                        fields[i] = this;
                                        i++;
                                    });
                                $(':hidden', this).each(
                                    function(){
                                    	if ( fields[0].value=='MM' &#038;&#038; fields[1].value=='DD' &#038;&#038; fields[2].value=='YYYY' ){
                                    		this.value = '';
									    } else if ( fields[0].value=='' &#038;&#038; fields[1].value=='' &#038;&#038; fields[2].value=='' ){
                                    		this.value = '';
									    } else {
	                                        this.value = fields[0].value+'/'+fields[1].value+'/'+fields[2].value;
	                                    }
                                    });
                            });
                        return mce_validator.form();
                    }, 
                    success: mce_success_cb
                };
      $('#mc-embedded-subscribe-form').ajaxForm(options);      </p>
<p>    });
}
function mce_success_cb(resp){
    $('#mce-success-response').hide();
    $('#mce-error-response').hide();
    if (resp.result=="success"){
        $('#mce-'+resp.result+'-response').show();
        $('#mce-'+resp.result+'-response').html(resp.msg);
        $('#mc-embedded-subscribe-form').each(function(){
            this.reset();
    	});
    } else {
        var index = -1;
        var msg;
        try {
            var parts = resp.msg.split(' - ',2);
            if (parts[1]==undefined){
                msg = resp.msg;
            } else {
                i = parseInt(parts[0]);
                if (i.toString() == parts[0]){
                    index = parts[0];
                    msg = parts[1];
                } else {
                    index = -1;
                    msg = resp.msg;
                }
            }
        } catch(e){
            index = -1;
            msg = resp.msg;
        }
        try{
            if (index== -1){
                $('#mce-'+resp.result+'-response').show();
                $('#mce-'+resp.result+'-response').html(msg);            
            } else {
                err_id = 'mce_tmp_error_msg';
                html = '
<div id="'+err_id+'" style="'+err_style+'"> '+msg+'</div>
<p>';</p>
<p>                var input_id = '#mc_embed_signup';
                var f = $(input_id);
                if (ftypes[index]=='address'){
                    input_id = '#mce-'+fnames[index]+'-addr1';
                    f = $(input_id).parent().parent().get(0);
                } else if (ftypes[index]=='date'){
                    input_id = '#mce-'+fnames[index]+'-month';
                    f = $(input_id).parent().parent().get(0);
                } else {
                    input_id = '#mce-'+fnames[index];
                    f = $().parent(input_id).get(0);
                }
                if (f){
                    $(f).append(html);
                    $(input_id).focus();
                } else {
                    $('#mce-'+resp.result+'-response').show();
                    $('#mce-'+resp.result+'-response').html(msg);
                }
            }
        } catch(e){
            $('#mce-'+resp.result+'-response').show();
            $('#mce-'+resp.result+'-response').html(msg);
        }
    }
}</p>
<p></script><br />
<!--End mc_embed_signup--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.lonhosford.com/lonblog/2011/05/22/xcode-4-iphone-mountains-of-the-usa-tutorial-lesson-6-add-slider-to-search-by-elevation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
