<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3770203940285232860</id><updated>2026-06-16T02:16:57.807-07:00</updated><category term="iOS"/><category term="Xcode"/><category term="programming"/><category term="Objective-C"/><category term="iOS 5"/><category term="Xcode 4.3"/><category term="iphone"/><category term="iOS 7"/><category term="Xcode 4"/><category term="Xcode 5"/><category term="Core Graphics"/><category term="UITableViewCell"/><category term="Xcode 4.5"/><category term="iOS 6"/><category term="ipad"/><category term="Core Animation"/><category term="Custom Fonts"/><category term="Decimal Pad"/><category term="Git"/><category term="NSUserDefaults"/><category term="UIBarButtonItem"/><category term="UIFont"/><category term="UINavigationBar"/><category term="UIPanGestureRecognizer"/><category term="UITableView"/><category term="books"/><category term="core data"/><category term="iAd"/><category term="iOS 8"/><category term="iOS6"/><category term="plist"/><category term="programm"/><title type='text'>iOS Programming Tutorials</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>29</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-8133511026799318200</id><published>2014-12-21T17:22:00.001-08:00</published><updated>2014-12-21T17:24:30.238-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS 8"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Best resources for iOS 8 developers.</title><content type='html'>To be able to develop for the iOS platform, you have to know Objective-C/Swift and learn how to use the iOS frameworks.&lt;br /&gt;
&lt;br /&gt;
Some of the best books to get started with Objective-C/Swift.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00GSRITM0/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00GSRITM0&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Objective-C Programming: The Big Nerd Ranch Guide&lt;/a&gt;&lt;br /&gt;
&amp;nbsp;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00GSRITM0/ref=as_li_ss_il?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00GSRITM0&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B00GSRITM0&amp;amp;Format=_SL160_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B00GSRITM0&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;br /&gt;
Based on Big Nerd Ranch&#39;s popular Objective-C Bootcamp, Objective-C Programming: The Big Nerd Ranch Guide covers C, Objective-C, and the common programming idioms that enable developers to make the most of Apple technologies. Compatible with Xcode 5, iOS 7, and OS X Mavericks (10.9), this guide features short chapters and an engaging style to keep you motivated and moving forward. At the same time, it encourages you to think critically as a programmer.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/1491908904/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=1491908904&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&amp;amp;linkId=FRIX2MF2WMDE43PI&quot; target=&quot;_blank&quot;&gt;iOS 8 Programming Fundamentals with Swift: Xcode and Cocoa Basics&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/1491908904/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=1491908904&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&amp;amp;linkId=FRIX2MF2WMDE43PI&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=1491908904&amp;amp;Format=_SL250_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=1491908904&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;br /&gt;
Get a clear view of iOS 8’s fundamental building blocks, including Xcode 6, Cocoa Touch, and Swift—Apple’s new programming language. Completely rewritten for Swift, this practical guide helps you learn the new language, understand how to use Apple’s development tools, and discover how Cocoa provides the underlying functionality iOS apps need to have. It’s ideal whether you’re getting started with iOS development, or want a firmer grasp of the basics.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once you know the basics of Objective-C and Swift you are ready to learn the iOS frameworks.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/1491908734/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=1491908734&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&amp;amp;linkId=6JBILWH5THHOLKCV&quot; target=&quot;_blank&quot;&gt;Programming iOS 8: Dive Deep into Views, View Controllers, and Frameworks&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/1491908734/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=1491908734&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&amp;amp;linkId=6JBILWH5THHOLKCV&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=1491908734&amp;amp;Format=_SL250_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=1491908734&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;

&lt;br /&gt;
&lt;br /&gt;
Start building apps for iOS 8 with Apple’s Swift programming language. If you’re grounded in the basics of Xcode and the Cocoa framework, this book provides a structured explanation of all essential real-world iOS app components. Through deep exploration and copious code examples, you’ll learn how to create views, manipulate view controllers, and use iOS frameworks for adding features such as audio and video, access to user calendars and photos, and tracking the device’s location.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/0321942051/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321942051&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;iOS Programming: The Big Nerd Ranch Guide (4th Edition)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/0321942051/ref=as_li_ss_il?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321942051&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=0321942051&amp;amp;Format=_SL160_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0321942051&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;br /&gt;
After completing this book, you will have the know-how and the confidence you need to tackle iOS projects of your own. Based on Big Nerd Ranch’s popular iOS Bootcamp course and its well-tested materials and methodology, this bestselling guide teaches iOS concepts and coding in tandem. The result is instruction that is relevant and useful.&lt;br /&gt;
Throughout the book, the authors explain what’s important and share their insights into the larger context of the iOS platform. You get a real understanding of how iOS development works, the many features that are available, and when and where to apply what you’ve learned.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/1491908696/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=1491908696&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&amp;amp;linkId=UDFCPDE4XP6QHYVA&quot; target=&quot;_blank&quot;&gt;iOS 8 Swift Programming Cookbook: Solutions &amp;amp; Examples for iOS Apps&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/1491908696/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=1491908696&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&amp;amp;linkId=UDFCPDE4XP6QHYVA&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=1491908696&amp;amp;Format=_SL250_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=1491908696&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Entirely rewritten for Apple’s Swift programming language, this updated cookbook helps you overcome the vexing issues you’re likely to face when creating apps for iOS devices.&lt;br /&gt;
&lt;br /&gt;
You’ll find hundreds of new and revised recipes for using the iOS 8 SDK, including techniques for working with Health data and HomeKit accessories, enhancing and animating graphics, storing and protecting data, sending and receiving notifications, and managing files and folders among them. Each recipe includes sample code on GitHub that you can use right away.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Last but not least the &lt;a href=&quot;http://online.stanford.edu/course/developing-ios7-apps-fall-2013&quot; target=&quot;_blank&quot;&gt;Developing iOS Apps for iPhone and iPad&lt;/a&gt;&amp;nbsp;online course made available for free by Stanford University.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider making a bitcoin donation:&amp;nbsp;&lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/8133511026799318200/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/12/best-resources-for-ios-8-developers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8133511026799318200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8133511026799318200'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/12/best-resources-for-ios-8-developers.html' title='Best resources for iOS 8 developers.'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-5746898338680574745</id><published>2014-05-12T17:07:00.001-07:00</published><updated>2014-10-13T03:39:01.155-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iAd"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>How to add an iAd banner to an iOS app</title><content type='html'>There are two parts to being able to serve ads to your users through the iAd network in your apps. &amp;nbsp;The first part is enabling iAd in iTunes connect by supplying your info to Apple. &amp;nbsp;The second part is implementing the code in your app to serve those ads.&lt;br /&gt;
&lt;br /&gt;
To complete part I login into&amp;nbsp;itunesconnect.apple.com and go to the section &quot;Contracts, Tax, and Banking.&quot; &amp;nbsp;Look for the &quot;iAd App Network&quot; type of contract and request it. &amp;nbsp;After that, supply your bank, contact and tax info. &amp;nbsp;Once your new contract is in effect you are ready to move to the second part.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The second part is to implement the code in your app. &amp;nbsp;Start a new &quot;Single View Application&quot; project in Xcode. &amp;nbsp;First add the iAd framework to our project. &amp;nbsp;If you don&#39;t know how to do this, follow &lt;a href=&quot;http://code-and-coffee.blogspot.com/2012/09/how-to-add-frameworks-in-xcode-4.html&quot; target=&quot;_blank&quot;&gt;this tutorial&lt;/a&gt;. &amp;nbsp;Next, open ViewController.h and import the iAd framework. &amp;nbsp;Also, declare that the class conforms to the&amp;nbsp;ADBannerViewDelegate protocol. &amp;nbsp;At this point ViewController.h should look like the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdbWoM8y5m5MKYpHgdSblAwYr05DXIWI_WKq1idrecExJi8ItDAH_ZCdRS4v5gnY90jNb2ngY35o3rqFutye-xizlfUTwpZ2hSSVnHun2Cql4J4NXaK_BNRH6SfkXL_XmRDY1Hn9_XxpY/s1600/28_ViewController_h.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdbWoM8y5m5MKYpHgdSblAwYr05DXIWI_WKq1idrecExJi8ItDAH_ZCdRS4v5gnY90jNb2ngY35o3rqFutye-xizlfUTwpZ2hSSVnHun2Cql4J4NXaK_BNRH6SfkXL_XmRDY1Hn9_XxpY/s1600/28_ViewController_h.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We need to implement two delegate methods in ViewController.m &amp;nbsp;The first method bannerViewDidLoadAd: is called when the ad is available to be displayed. &amp;nbsp;In this case we animate the adbanner alpha value from 0 to 1. &amp;nbsp;The second method&amp;nbsp;bannerView: didFailToReceiveAdWithError: is called when an ad fails to load. &amp;nbsp;In that case we animate the alpha value from 1 to 0. &amp;nbsp;Add the following code at the bottom of ViewController.m&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    [UIView animateWithDuration:1.0 animations:^{[banner setAlpha:1.0];
                                                }];
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    [UIView animateWithDuration:1.0 animations:^{[banner setAlpha:0.0];
                                                }];
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
The final step is to add the ad banner view. &amp;nbsp;Open Main.storyboard and drag an ad banner view from the object library to the canvas. &amp;nbsp;Right click on the banner and set its delate property by dragging from the delegate outlet to the View Controller class.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGguacdk3jMvvOFbNgFQvrkn5hxdC_vtjvGa1MpTypOJR9UOH56qqMsUK-eBQTKnSt_yaubGbnU0sXCWqLJaAiWQ2ko_tzaHpGxymTmRDywkFIqWMtwp3tqsyLPoEI19wDpjBqCO6Yzqo/s1600/28_set_delegate.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGguacdk3jMvvOFbNgFQvrkn5hxdC_vtjvGa1MpTypOJR9UOH56qqMsUK-eBQTKnSt_yaubGbnU0sXCWqLJaAiWQ2ko_tzaHpGxymTmRDywkFIqWMtwp3tqsyLPoEI19wDpjBqCO6Yzqo/s1600/28_set_delegate.png&quot; height=&quot;168&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
You can run the app at this point and it should load ads if there are any available. &amp;nbsp;Read the Apple docs on iAd for more details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider making a BTC donation:
&lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt; 

&lt;img src=&quot;https://www.linkedin.com/profile/view?authToken=zRgB&amp;authType=name&amp;id=361518299&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/5746898338680574745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/05/how-to-add-iad-banner-to-ios-app.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/5746898338680574745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/5746898338680574745'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/05/how-to-add-iad-banner-to-ios-app.html' title='How to add an iAd banner to an iOS app'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdbWoM8y5m5MKYpHgdSblAwYr05DXIWI_WKq1idrecExJi8ItDAH_ZCdRS4v5gnY90jNb2ngY35o3rqFutye-xizlfUTwpZ2hSSVnHun2Cql4J4NXaK_BNRH6SfkXL_XmRDY1Hn9_XxpY/s72-c/28_ViewController_h.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-62129711699997072</id><published>2014-02-20T22:24:00.001-08:00</published><updated>2014-03-06T03:06:18.326-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS 7"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 5"/><title type='text'>How to make a countdown app</title><content type='html'>In this tutorial we are going to make a simple app that counts the time left to a specific date that we set. &amp;nbsp;It can be somebody&#39;s birthday or anniversary.&lt;br /&gt;
&lt;br /&gt;
Open Xcode and start a new single view application project. &amp;nbsp;I named my project Countdown.&lt;br /&gt;
&lt;br /&gt;
First we have to layout the user interface. &amp;nbsp;Open Main.storyboard and drag a UIDatePicker, &amp;nbsp;a UILabel, and a UIButton to the view controller scene. &amp;nbsp;Change the titles of the buttons and the label so they look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-j92ZIPuApeVHPJ12R2mXb2mcN0CIRd8p9u_DqnjUm9R1hz3y0JVOeSFIfsEGALVwZLk3RMNSNpQFzkASxBGElJYE0vXIbNksPA_rFAdgy88lsyZlCFWM0BmUNFdUaHphRUucTrqBNgY/s1600/27_set_ui.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-j92ZIPuApeVHPJ12R2mXb2mcN0CIRd8p9u_DqnjUm9R1hz3y0JVOeSFIfsEGALVwZLk3RMNSNpQFzkASxBGElJYE0vXIbNksPA_rFAdgy88lsyZlCFWM0BmUNFdUaHphRUucTrqBNgY/s1600/27_set_ui.png&quot; height=&quot;640&quot; width=&quot;470&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
If you run the app right now, you will see that the date picker asks about the day and the time. &amp;nbsp;We have to configure the date picker to ask only about the date. &amp;nbsp;Click on the date picker in the storyboard and go to the attributes inspector (option+command+4) &amp;nbsp;Change the date picker mode to date. &amp;nbsp;It is the first option in the attributes inspector.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxZgEOnNX0pN1B5zqWGeVC7P16zqQNgd_4-HwULETw4dYU4Tgqg40HW69RwojHZFD8xDFTc-yJiwv6WTRvBSWD953gHe36519OATUbgjkTelUehQB9rJbVLxMdSg1z3XJsCLUTp6VQBNM/s1600/27_set_date_picker_mode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxZgEOnNX0pN1B5zqWGeVC7P16zqQNgd_4-HwULETw4dYU4Tgqg40HW69RwojHZFD8xDFTc-yJiwv6WTRvBSWD953gHe36519OATUbgjkTelUehQB9rJbVLxMdSg1z3XJsCLUTp6VQBNM/s1600/27_set_date_picker_mode.png&quot; height=&quot;528&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Next, we have to set the outlets for the label and date picker. &amp;nbsp;We also need to set the action when the button is pressed. &amp;nbsp;Open the assistant editor by clicking on the tuxedo icon in Xcode or holding down option key and clicking on the ViewController.h file in the project navigator.&lt;br /&gt;
&lt;br /&gt;
To set the outlets hold down control and drag from the date picker to the ViewController.h file between the @interface and @end directives. &amp;nbsp;Name the outlet datePicker.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ4Easv8S6ojGJYjhuJtxfl70lAi3ssaEThDiRGSimxDdj32kGQvWptnCyHiIAIl8tMyj2Kg-ADXTe5Pe7spwgBmEvRuzSBMTnV3-vpy4TIzmPBdM6t3rFHgpwGmdW0Ur_LDeptIKyOQs/s1600/27_set_outlets.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ4Easv8S6ojGJYjhuJtxfl70lAi3ssaEThDiRGSimxDdj32kGQvWptnCyHiIAIl8tMyj2Kg-ADXTe5Pe7spwgBmEvRuzSBMTnV3-vpy4TIzmPBdM6t3rFHgpwGmdW0Ur_LDeptIKyOQs/s1600/27_set_outlets.png&quot; height=&quot;446&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Do the same for the label outlet, but name it countdownLabel.&lt;br /&gt;
&lt;br /&gt;
To set the button action control+drag again but change the connection type to action. &amp;nbsp;Name the action startCountdown.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhydYE9NmYFYy7uL4mEZaFTSHB3exevift43REUCgy-7gQALWTkv6LFCQimjKuLmrBvgCPSb4i-zJ-1bPCU-6L-Mo9J6F_0ITyOhWKOJkYJfVzOQpnsAneX80wgOpCXE48y2DW9LiGhmkM/s1600/27_set_action.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhydYE9NmYFYy7uL4mEZaFTSHB3exevift43REUCgy-7gQALWTkv6LFCQimjKuLmrBvgCPSb4i-zJ-1bPCU-6L-Mo9J6F_0ITyOhWKOJkYJfVzOQpnsAneX80wgOpCXE48y2DW9LiGhmkM/s1600/27_set_action.png&quot; height=&quot;390&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The last thing that we need to do is implement the action method. &amp;nbsp;Open ViewController.m and find the&amp;nbsp;-(IBAction)startCountdown:(id)sender method. &amp;nbsp;When we set the date for the countdown, the UIDatePicker sets the time to the current time. &amp;nbsp;Since we don&#39;t care about the time we should remove it and leave only the date. &amp;nbsp;After that we set up a timer that calls a method every second and updates the label with the time countdown. &amp;nbsp;We will call -(void)updateTime for this purpose. &amp;nbsp;Inside updateTime we calculate how much time is left until the date and update the label. &amp;nbsp;Add the following code to the ViewController.m file and read the comments for explanation what each part of the code does.&lt;br /&gt;
&lt;span style=&quot;font-family: Menlo;&quot;&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;- (IBAction)startCountdown:(id)sender {
    //Remove the time component from the datePicker.  We care only about the date
    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
    NSUInteger preservedComponents = (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit);
    self.datePicker.date = [calendar dateFromComponents:[calendar components:preservedComponents fromDate:self.datePicker.date]];

    //Set up a timer that calls the updateTime method every second to update the label
    NSTimer *timer;
    timer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                             target:self
                                           selector:@selector(updateTime)
                                           userInfo:nil
                                            repeats:YES];
}

-(void)updateTime
{
    //Get the time left until the specified date
    NSInteger ti = ((NSInteger)[self.datePicker.date timeIntervalSinceNow]);
    NSInteger seconds = ti % 60;
    NSInteger minutes = (ti / 60) % 60;
    NSInteger hours = (ti / 3600) % 24;
    NSInteger days = (ti / 86400);
    
    //Update the label with the remaining time
    self.countdownLabel.text = [NSString stringWithFormat:@&quot;%02i days %02i hrs %02i min %02i sec&quot;, days, hours, minutes, seconds];
}&lt;/code&gt;&lt;/pre&gt;
You can run the app (command+R) in the simulator. &amp;nbsp;Pick some date in the future and press the start countdown button.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkQXyqWtQaziSe7MK97Cny5L4RNpQlyTEwBuxbCaTdyyN44HIGe8joGG1S-bBwCoT_HaZFHsv0nK7tiqm77UzvNlvuUxy6rKlYPLmjhfcz_ZHgIqY3SZ8jxeC7FlVdBb9cTBhyphenhyphen7OsELJM/s1600/27_countdown_app.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkQXyqWtQaziSe7MK97Cny5L4RNpQlyTEwBuxbCaTdyyN44HIGe8joGG1S-bBwCoT_HaZFHsv0nK7tiqm77UzvNlvuUxy6rKlYPLmjhfcz_ZHgIqY3SZ8jxeC7FlVdBb9cTBhyphenhyphen7OsELJM/s1600/27_countdown_app.png&quot; height=&quot;640&quot; width=&quot;426&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
You can download the source code for this tutorial from &lt;a href=&quot;https://github.com/code-and-coffee/Countdown&quot; target=&quot;_blank&quot;&gt;github&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider making a BTC donation:
&lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt; 

</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/62129711699997072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/02/how-to-make-countdown-app.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/62129711699997072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/62129711699997072'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/02/how-to-make-countdown-app.html' title='How to make a countdown app'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-j92ZIPuApeVHPJ12R2mXb2mcN0CIRd8p9u_DqnjUm9R1hz3y0JVOeSFIfsEGALVwZLk3RMNSNpQFzkASxBGElJYE0vXIbNksPA_rFAdgy88lsyZlCFWM0BmUNFdUaHphRUucTrqBNgY/s72-c/27_set_ui.png" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-1864473078801200026</id><published>2014-02-09T22:17:00.000-08:00</published><updated>2014-02-09T22:17:21.954-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS 7"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 5"/><title type='text'>How to make a simple iPhone app: Trip Cost Calculator</title><content type='html'>In this tutorial, we are going to make a simple app that calculates the cost of taking a trip by car. &amp;nbsp;We will have text fields where we input the price of gas, mpg (mile per gallon,) and the distance of the trip.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s start by opening Xcode and starting a new &quot;Single View Application&quot; project. &amp;nbsp;Name the project &quot;Trip Cost Calculator&quot; and save it.&lt;br /&gt;
&lt;br /&gt;
Open Main.storyboard and drag three UITextFields from the object library (lower-right corner in Xcode) to the ViewController scene. &amp;nbsp;Also, drag three UILabels and change their text (by double clicking on them) to explain what each text field is for. &amp;nbsp;Your scene should look like the following when done:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFp_eeLXwprE5Khc78-gsDIKPsVJDQScfJziDVrbXL4e7PLUvb7Dt0mG5_vdncLyLG8D6gwgrW2dU9Qimi-G8p4I4QPCqrpnRreqVg2rRwRldkjl3e_wEKLfhqpd8_Qz99k7RET89M998/s1600/26_add_labels_and_textfields.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFp_eeLXwprE5Khc78-gsDIKPsVJDQScfJziDVrbXL4e7PLUvb7Dt0mG5_vdncLyLG8D6gwgrW2dU9Qimi-G8p4I4QPCqrpnRreqVg2rRwRldkjl3e_wEKLfhqpd8_Qz99k7RET89M998/s1600/26_add_labels_and_textfields.png&quot; height=&quot;640&quot; width=&quot;536&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Next we need to add a button that does the calculations when pressed. &amp;nbsp;We also need to add two more labels that show the calculated cost. &amp;nbsp;Drag a UIButton from the object library and two more labels to the scene. &amp;nbsp;Change their text to the following:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmJ3gAyPrTIHKC1f9a0TZ9eyyLtB5_a6oFz8hlAmUDgFHMqa5vMa4WvtxLnNwmqDnxdIe2RISjXXAzrb5Y6atr2GSa_xYaMfyDgO95Kmp7Twp2gWTm1eWeuSp35TmTeyzt1CMIP_bV0Uc/s1600/26_add_calculate_button_and_lables.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmJ3gAyPrTIHKC1f9a0TZ9eyyLtB5_a6oFz8hlAmUDgFHMqa5vMa4WvtxLnNwmqDnxdIe2RISjXXAzrb5Y6atr2GSa_xYaMfyDgO95Kmp7Twp2gWTm1eWeuSp35TmTeyzt1CMIP_bV0Uc/s1600/26_add_calculate_button_and_lables.png&quot; height=&quot;640&quot; width=&quot;530&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
At this point if you run the app in the simulator and press on one of the text fields, a keyboard appears but with letters. &amp;nbsp;We want numerical keys instead. &amp;nbsp;We have to change this behavior. &amp;nbsp;For each text field, select it and go to the &quot;Attributes Inspector&quot; (option+command+4) and change the keyboard type to &quot;Decimal Pad&quot;:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyYNdMx6mVLZVJvNv2u8BlLk4KAKg9CSlUJimIJEebvzINTwSLpaiYrxcC-Yt6wTF9w4gjzxtlIzwHYh_8MUruHXW0tgZKUoZoq211j2w4fPl6w60JBIQ5OthDFVTM2axS2h_XswUlx-0/s1600/26_change_keyboard.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyYNdMx6mVLZVJvNv2u8BlLk4KAKg9CSlUJimIJEebvzINTwSLpaiYrxcC-Yt6wTF9w4gjzxtlIzwHYh_8MUruHXW0tgZKUoZoq211j2w4fPl6w60JBIQ5OthDFVTM2axS2h_XswUlx-0/s1600/26_change_keyboard.png&quot; height=&quot;520&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
There is one more thing left to do in IB and we can move away from it. &amp;nbsp;We need to set the outlets for the textfields and the label which will show the total cost. &amp;nbsp;We also need to set the action for the calculate button. &amp;nbsp;Open the &quot;Assistant editor.&quot; &amp;nbsp;This can be done by clicking on the tuxedo icon or by holding down the option key and clicking on ViewController.h in the project navigator. &amp;nbsp;When you have the &quot;Assistant editor&quot; open, you should have the Main.storyboard on the left and ViewController.h on the right side. &amp;nbsp;Hold down the control button on the keyboard and drag from the first text field to the ViewController.h file between @interface and @end. &amp;nbsp;When you release the mouse, the connection dialog appears. &amp;nbsp;Name it pricePerGallon, keep everything else as is and press connect. &amp;nbsp;Do the same for the rest of the text fields, but name them mpg and distance.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsJUD-FzWWWlRj6_dHAFzp5MRG2bwJNBytYus9WFNyT6YJokfnu5idrRvl3XVKsYjRZUFk2WSqecHo3qGyVpQ7QOwaauVwxFSmmRfuMPWqcxPZGyaPSLFF1rFD4CPne5qWW9ux2kfpIvE/s1600/26_connect_outlets.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsJUD-FzWWWlRj6_dHAFzp5MRG2bwJNBytYus9WFNyT6YJokfnu5idrRvl3XVKsYjRZUFk2WSqecHo3qGyVpQ7QOwaauVwxFSmmRfuMPWqcxPZGyaPSLFF1rFD4CPne5qWW9ux2kfpIvE/s1600/26_connect_outlets.png&quot; height=&quot;382&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp;Do the same control+drag for the label that shows the total cost and name it totalCost.&lt;br /&gt;
&lt;br /&gt;
We also need to set the action that calculates the cost of the trip. &amp;nbsp;Control+drag from the calculate button, same as above, but this time change the connection to Action and name it calculate.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuHjD4ECOorjYyXlV8VzNp0HeKQoWX5KPJhf4n7DytwQKgNGFZgE9xvVXpGJQVLEwujiOS-tGh7VPxchemz9_N24N2Z7ooWv7MKs6XuI-0EBXaedUKW1qKD21F_41kowLpq_3LUzswTLM/s1600/26_set_action.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuHjD4ECOorjYyXlV8VzNp0HeKQoWX5KPJhf4n7DytwQKgNGFZgE9xvVXpGJQVLEwujiOS-tGh7VPxchemz9_N24N2Z7ooWv7MKs6XuI-0EBXaedUKW1qKD21F_41kowLpq_3LUzswTLM/s1600/26_set_action.png&quot; height=&quot;322&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
If you have done everything right, your ViewController.h file should contain the following:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;@property (weak, nonatomic) IBOutlet UITextField *pricePerGallon;
@property (weak, nonatomic) IBOutlet UITextField *mpg;
@property (weak, nonatomic) IBOutlet UITextField *distance;
@property (weak, nonatomic) IBOutlet UILabel *totalCost;
- (IBAction)calculate:(id)sender;
&lt;/code&gt;&lt;/pre&gt;
At this point we are done with IB and the last thing we have to do is go and implement the calculate method in ViewController.m&lt;br /&gt;
&lt;br /&gt;
First thing we want to do when the user clicks the calculate button is to check that all fields are filled. If they are not, we show an alert message. &amp;nbsp;Then we read all the data from the text fields, set a formatter for the dollar amount, do the calculation, and set the totalCost label. &amp;nbsp;This is what the method should look like when finished. &amp;nbsp;Follow the comments for explanation of each part.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;- (IBAction)calculate:(id)sender {
    //check that all the fields are filled up properly
    if ([self.pricePerGallon.text doubleValue] == 0 || [self.mpg.text doubleValue] == 0 || [self.distance.text doubleValue] == 0){
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@&quot;Not all fields are filled&quot;
                                                        message:nil delegate:nil
                                              cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil];
        [alert show];
        
        return;
    }
    
    //create NSNumberFormatter to be able to show currency
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
    [numberFormatter setMaximumFractionDigits:2];
    
    //Calculate total cost of trip
    NSNumber *total = [NSNumber numberWithDouble:(([self.distance.text doubleValue] / [self.mpg.text doubleValue]) * [self.pricePerGallon.text doubleValue])];
    
    //Set the total cost label
    self.totalCost.text = [numberFormatter stringFromNumber:total];
    
    //Dismiss the keyboard
    [self.view endEditing:YES];
}&lt;/code&gt;&lt;/pre&gt;
If you run (command+R) the app in the simulator, you should be able to calculate the cost of trip.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9f-2TiOCTE1-zzPzv5gBx9BXJRBtl7GRPmU_n2m9Zqv2gKJmT88frsToh0uDD5pq5NvvaxtElwcgGJ7n6evfnUSUt0fiMq8S-LDjIwxKkYVaVI0d6bAVXWnpFLJaipg_RVgko7TeqH3M/s1600/26_finished_app.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9f-2TiOCTE1-zzPzv5gBx9BXJRBtl7GRPmU_n2m9Zqv2gKJmT88frsToh0uDD5pq5NvvaxtElwcgGJ7n6evfnUSUt0fiMq8S-LDjIwxKkYVaVI0d6bAVXWnpFLJaipg_RVgko7TeqH3M/s1600/26_finished_app.png&quot; height=&quot;640&quot; width=&quot;426&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
You can download the source code for this tutorial from &lt;a href=&quot;https://github.com/code-and-coffee/Trip-Cost-Calculator/archive/master.zip&quot; target=&quot;_blank&quot;&gt;github&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider making a bitcoin donation:&amp;nbsp;&lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/1864473078801200026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/02/how-to-make-simple-iphone-app-trip-cost.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/1864473078801200026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/1864473078801200026'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/02/how-to-make-simple-iphone-app-trip-cost.html' title='How to make a simple iPhone app: Trip Cost Calculator'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFp_eeLXwprE5Khc78-gsDIKPsVJDQScfJziDVrbXL4e7PLUvb7Dt0mG5_vdncLyLG8D6gwgrW2dU9Qimi-G8p4I4QPCqrpnRreqVg2rRwRldkjl3e_wEKLfhqpd8_Qz99k7RET89M998/s72-c/26_add_labels_and_textfields.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-9048236049031582781</id><published>2014-02-04T08:31:00.001-08:00</published><updated>2014-02-04T08:31:26.080-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS 7"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Best resources for iOS 7 developers</title><content type='html'>To be able to develop for the iOS platform, you have to know Objective-C and learn how to use the iOS frameworks.&lt;br /&gt;
&lt;br /&gt;
Some of the best books to get started with Objective-C.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00GSRITM0/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00GSRITM0&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Objective-C Programming: The Big Nerd Ranch Guide&lt;/a&gt;&lt;br /&gt;
&amp;nbsp;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00GSRITM0/ref=as_li_ss_il?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00GSRITM0&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B00GSRITM0&amp;amp;Format=_SL160_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B00GSRITM0&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;br /&gt;
Based on Big Nerd Ranch&#39;s popular Objective-C Bootcamp, Objective-C Programming: The Big Nerd Ranch Guide covers C, Objective-C, and the common programming idioms that enable developers to make the most of Apple technologies. Compatible with Xcode 5, iOS 7, and OS X Mavericks (10.9), this guide features short chapters and an engaging style to keep you motivated and moving forward. At the same time, it encourages you to think critically as a programmer.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00FT7KW3Y/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00FT7KW3Y&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;iOS 7 Programming Fundamentals: Objective-C, Xcode, and Cocoa Basics&lt;/a&gt;&lt;/div&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00FT7KW3Y/ref=as_li_ss_il?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00FT7KW3Y&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B00FT7KW3Y&amp;amp;Format=_SL160_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B00FT7KW3Y&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;br /&gt;
If you want to build an app optimized for iPhone or iPad, you need a thorough understanding of the Objective-C language, the Cocoa API, and the Xcode development environment. This practical guide walks you through the fundamentals of these iOS building blocks, complete with easy-to-follow code examples. By learning how to navigate the idiosyncrasies of this framework, you’ll be able to create a clean, fundamentally sound iOS app.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once you know Objective-C you are ready to learn the iOS frameworks.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00H8B64BI/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00H8B64BI&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Programming iOS 7&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00H8B64BI/ref=as_li_ss_il?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00H8B64BI&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B00H8B64BI&amp;amp;Format=_SL160_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B00H8B64BI&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;br /&gt;
If you’re grounded in the basics of Objective-C and Xcode, this practical guide takes you through the components you need for building your own iOS apps. With examples from real apps and programming situations, you’ll learn how to create views, manipulate view controllers, and use iOS frameworks for adding features such as audio and video.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/0321942051/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321942051&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;iOS Programming: The Big Nerd Ranch Guide (4th Edition)&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/0321942051/ref=as_li_ss_il?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0321942051&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=0321942051&amp;amp;Format=_SL160_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0321942051&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;br /&gt;
Updated and expanded to cover iOS 7 and Xcode 5, iOS Programming: The Big Nerd Ranch Guide leads you through the essential concepts, tools, and techniques for developing iOS applications. After completing this book, you will have the know-how and the confidence you need to tackle iOS projects of your own. Based on Big Nerd Ranch’s popular iOS Bootcamp course and its well-tested materials and methodology, this bestselling guide teaches iOS concepts and coding in tandem. The result is instruction that is relevant and useful.&lt;br /&gt;
Throughout the book, the authors explain what’s important and share their insights into the larger context of the iOS platform. You get a real understanding of how iOS development works, the many features that are available, and when and where to apply what you’ve learned.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00FW79LHE/ref=as_li_ss_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00FW79LHE&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;iOS 7 Programming Cookbook&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.amazon.com/gp/product/B00FW79LHE/ref=as_li_ss_il?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=B00FW79LHE&amp;amp;linkCode=as2&amp;amp;tag=httpcodeandco-20&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&amp;amp;ASIN=B00FW79LHE&amp;amp;Format=_SL160_&amp;amp;ID=AsinImage&amp;amp;MarketPlace=US&amp;amp;ServiceVersion=20070822&amp;amp;WS=1&amp;amp;tag=httpcodeandco-20&quot; /&gt;&lt;/a&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=httpcodeandco-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B00FW79LHE&quot; height=&quot;1&quot; style=&quot;border: none !important; margin: 0px !important;&quot; width=&quot;1&quot; /&gt;
&lt;br /&gt;
Overcome the vexing issues you’re likely to face when creating apps for the iPhone, iPad, or iPod touch. With new and thoroughly revised recipes in this updated cookbook, you’ll quickly learn the steps necessary to work with the iOS 7 SDK, including solutions for bringing real-world physics and movement to your apps with UIKit Dynamics APIs.&lt;br /&gt;
You’ll learn hundreds of techniques for storing and protecting data, sending and receiving notifications, enhancing and animating graphics, managing files and folders, and many other options. Each recipe includes sample code you can use right away.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Last but not least the &lt;a href=&quot;http://online.stanford.edu/course/developing-ios7-apps-fall-2013&quot; target=&quot;_blank&quot;&gt;Developing iOS 7 Apps for iPhone and iPad&lt;/a&gt;&amp;nbsp;online course made available for free by Stanford University.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider making a bitcoin donation:&amp;nbsp;&lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/9048236049031582781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/02/best-resources-for-ios-7-developers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/9048236049031582781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/9048236049031582781'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/02/best-resources-for-ios-7-developers.html' title='Best resources for iOS 7 developers'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-8859383666728353816</id><published>2014-02-03T07:59:00.000-08:00</published><updated>2014-02-03T07:59:00.033-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS 7"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 5"/><title type='text'>Why you should use @import instead of #import in iOS 7</title><content type='html'>When Xcode 5 was introduced, modules and auto-linking were some of the new features added to make developing for iOS and Mac OS X easier. Using the directive @import to add frameworks to your projects is more efficient than using #import. &amp;nbsp;The release notes for Xcode 5 state:&lt;br /&gt;
&lt;br /&gt;
&quot;Modules for system frameworks speed build time and provide an alternate means to import APIs from the SDK instead of using the C preprocessor. Modules provide many of the build-time improvements of precompiled headers with less maintenance or need for optimization. They are designed for easy adoption with little or no source changes. Beyond build-time improvements, modules provide a cleaner API model that enables many great features in the tools, such as Auto Linking.&quot;&lt;br /&gt;
&lt;br /&gt;
Modules and auto-linking are enabled by default on new projects.  You can enable them on older projects in the build settings &quot;Language - Modules.&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMMR45lpKXUFtYM2ln726x0Te3yH-A8M8W537xd3UeHEKhAPuEoXSCvl8etGh6Y_hwOw8ig8CiELbt3naCcRQwxr8ACjsduPU5GioDIHrl7-TR5UPZAc_12E4xUTnxD8REBwXLXQfBToo/s1600/24_modules_setting.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMMR45lpKXUFtYM2ln726x0Te3yH-A8M8W537xd3UeHEKhAPuEoXSCvl8etGh6Y_hwOw8ig8CiELbt3naCcRQwxr8ACjsduPU5GioDIHrl7-TR5UPZAc_12E4xUTnxD8REBwXLXQfBToo/s400/24_modules_setting.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Another benefit of using modules besides their efficiency is that you no longer need to link the framework to your project.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
For example, in the past if you wanted you use the MapKit framework, you had to do the following steps:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
1) add&amp;nbsp;&lt;span style=&quot;color: #6e371a;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 15px; white-space: pre-wrap;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;#import &amp;lt;MapKit/MapKit.h&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
2) go to the projects build phases settings and link the MapKit.framework to the project.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
With modules you only have to add &quot;@import MapKit;&quot; and you can start using the framework. &amp;nbsp;There is no need to link the framework to the project.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider making a bitcoin donation:
&lt;br /&gt;
&lt;div&gt;
&lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/8859383666728353816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/02/why-you-should-use-import-instead-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8859383666728353816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8859383666728353816'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/02/why-you-should-use-import-instead-of.html' title='Why you should use @import instead of #import in iOS 7'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMMR45lpKXUFtYM2ln726x0Te3yH-A8M8W537xd3UeHEKhAPuEoXSCvl8etGh6Y_hwOw8ig8CiELbt3naCcRQwxr8ACjsduPU5GioDIHrl7-TR5UPZAc_12E4xUTnxD8REBwXLXQfBToo/s72-c/24_modules_setting.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-8752180497928905044</id><published>2014-01-16T17:27:00.001-08:00</published><updated>2014-02-02T13:23:45.893-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="UIPanGestureRecognizer"/><category scheme="http://www.blogger.com/atom/ns#" term="UITableViewCell"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>How to Delete UITableViewCells in a UITableView by Dragging Them Offscreen Using UIPanGestureRecognizer iOS7.</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
At the end of this tutorial you should be able to delete rows in a table view by dragging them offscreen to the right like in the following video.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;object class=&quot;BLOGGER-youtube-video&quot; classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot; data-thumbnail-src=&quot;https://ytimg.googleusercontent.com/vi/SXsGg_1lBU8/0.jpg&quot; height=&quot;266&quot; width=&quot;320&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;https://www.youtube.com/v/SXsGg_1lBU8?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata&quot; /&gt;&lt;param name=&quot;bgcolor&quot; value=&quot;#FFFFFF&quot; /&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot; /&gt;&lt;embed width=&quot;320&quot; height=&quot;266&quot;  src=&quot;https://www.youtube.com/v/SXsGg_1lBU8?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata&quot; type=&quot;application/x-shockwave-flash&quot; allowfullscreen=&quot;true&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;Start by creating a new &quot;Single View Application&quot; iPhone project in Xcode. &amp;nbsp;Delete both ViewController.h and ViewController.m files. &amp;nbsp;Open Main.storyboard and delete the view controller scene. &amp;nbsp;Find a Table View Controller in the object library and drag it to the storyboard canvas. &amp;nbsp;This is what your project should look like at this point.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipU9cmRHhya1LgYDQdaHJjZ1YbqUTSZpoCpXdGpeJLcGaydPyYBCzAQCgxZ6sBMLBGC_ff6KcOb6zTQw5Kxh62zbWONXNHWUYcDHGj_iYthfRB2A4qkJumu1aBIeqpbrWocOiR0u9_aqo/s1600/23_add_tableViewController_to_storyboard.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipU9cmRHhya1LgYDQdaHJjZ1YbqUTSZpoCpXdGpeJLcGaydPyYBCzAQCgxZ6sBMLBGC_ff6KcOb6zTQw5Kxh62zbWONXNHWUYcDHGj_iYthfRB2A4qkJumu1aBIeqpbrWocOiR0u9_aqo/s1600/23_add_tableViewController_to_storyboard.png&quot; height=&quot;398&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;Next, we need to add a new class called TableViewController that is a subclass of UITableViewController and will be the delegate and dataSource for the table view. &amp;nbsp;Start by creating a new file (command+N) class name: TableViewController and subclass of: UITableViewController. &amp;nbsp;Open Main.storyboard again select the scene available and open the identity inspector (option+command+3) and change the name of the Custom class to the class we just created: TableViewController.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMisr8C3ca13bmFWbIoy9qh8XJPxI3oLQKz-h3ivYt9StwL-JxIUVEo5aMtzPmmcZm_PIQHzwLpZ_pTh5dC58EcaN7I8tUSIjt2u7gEjXQZf-SeXgPy7cGYApojcTn_8AstybJite9FUc/s1600/23_change_custom_class.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMisr8C3ca13bmFWbIoy9qh8XJPxI3oLQKz-h3ivYt9StwL-JxIUVEo5aMtzPmmcZm_PIQHzwLpZ_pTh5dC58EcaN7I8tUSIjt2u7gEjXQZf-SeXgPy7cGYApojcTn_8AstybJite9FUc/s1600/23_change_custom_class.png&quot; height=&quot;358&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;The next step is to configure our data model and implement the methods that tell the table view what data to display. &amp;nbsp;Open TableViewController.m and add a property data of type NSMutableArray.&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;@interface TableViewController ()
@property (nonatomic, strong) NSMutableArray  *data;
@end&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&lt;span style=&quot;font-family: Helvetica; font-size: 13px; white-space: normal;&quot;&gt;We initialize the array in the getter method.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;-(NSArray *)data
{
    if (!_data) {
        _data = [NSMutableArray arrayWithArray:@[@&quot;cell 1&quot;, @&quot;cell 2&quot;, @&quot;cell 3&quot;, @&quot;cell 4&quot;, @&quot;cell 5&quot;, @&quot;cell 6&quot;, @&quot;cell 7&quot;]];
    }
    return _data;
}&lt;/code&gt;&lt;/pre&gt;
Delete the method -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView the default value is 1 and that is what we need. Time to implement - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section and - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)&amp;nbsp;

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [self.data count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @&quot;Cell&quot;;
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    
    // Configure the cell...
    cell.textLabel.text = [self.data objectAtIndex:indexPath.row];
    return cell;
}
&lt;/code&gt;&lt;/pre&gt;
Don’t forget to set the cell identifier in the storyboard.  Open Main.storyboard, click on the table view cell and open the attributes inspector (option+command+4) and set the identifier to Cell.
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4GKkMXt0dF-bVUUDEkJWnlvBs1AH4eFb-ZlWa6UlELlLsWs84q2lBAQ9oC9D046xmtIiQb_tiqEWNluvVP94t2X3ayHE5AFdpmK7tR_0dTGazzYkiWV2OWeuL7YDh_WL2EBSFbY9mcGY/s1600/23_set_cell_indentifier.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4GKkMXt0dF-bVUUDEkJWnlvBs1AH4eFb-ZlWa6UlELlLsWs84q2lBAQ9oC9D046xmtIiQb_tiqEWNluvVP94t2X3ayHE5AFdpmK7tR_0dTGazzYkiWV2OWeuL7YDh_WL2EBSFbY9mcGY/s1600/23_set_cell_indentifier.png&quot; height=&quot;358&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;If you run the app at this point you should see the following.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIP5P53_SD-AUD8lV7P3eqiZ88P0j6gfugpkI65vA08X_DzoZXeoXGtSd4dK2MO90kovc5s0G3X4XL9YvZniKEh3XVXpMgy6HuQR0kTm0jI4E5-iJOm8ovU5ksy55UNRjtutOxfsb5UvE/s1600/23_simulator_load_table.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIP5P53_SD-AUD8lV7P3eqiZ88P0j6gfugpkI65vA08X_DzoZXeoXGtSd4dK2MO90kovc5s0G3X4XL9YvZniKEh3XVXpMgy6HuQR0kTm0jI4E5-iJOm8ovU5ksy55UNRjtutOxfsb5UvE/s1600/23_simulator_load_table.png&quot; height=&quot;640&quot; width=&quot;426&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Helvetica; font-size: 13px;&quot;&gt;Next step is to add the pan gesture recognizer. &amp;nbsp;Open TableViewController.m and add the following to the viewDidLoad method.&lt;/span&gt;&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;- (void)viewDidLoad
{
    [super viewDidLoad];

    UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
    panGesture.delegate = self;
    
    [self.view addGestureRecognizer:panGesture];
}
&lt;/code&gt;&lt;/pre&gt;
There are two warnings showing at this point.  One of them tells us that the method handPan: is not implemented and the other one tells us that the TableViewController class doesn’t implement the UIGestureRecognizerDelegate protocol.  Let’s fix both of these problems.&lt;br /&gt;
&lt;br /&gt;
Add &amp;lt;UIGestureRecognizerDelegate&amp;gt; at the end of&lt;uigesturerecognizerdelegate&gt;&amp;nbsp;@interface TableViewController () to resolve the warning about the protocol.&amp;nbsp;&lt;uigesturerecognizerdelegate&gt;&amp;nbsp;&lt;/uigesturerecognizerdelegate&gt;&lt;/uigesturerecognizerdelegate&gt;&lt;br /&gt;
&lt;uigesturerecognizerdelegate&gt;&lt;uigesturerecognizerdelegate&gt;&lt;br /&gt;&lt;/uigesturerecognizerdelegate&gt;&lt;/uigesturerecognizerdelegate&gt;
&lt;uigesturerecognizerdelegate&gt;&lt;uigesturerecognizerdelegate&gt;- (void)handlePan:(UIPanGestureRecognizer *)panGesture it is a long method so follow the comments for explanation&lt;/uigesturerecognizerdelegate&gt;&lt;/uigesturerecognizerdelegate&gt;&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;- (void)handlePan:(UIPanGestureRecognizer *)panGesture {
    //check if the pan gesture just ended
    if (panGesture.state == UIGestureRecognizerStateEnded) {
        
        //check how far was the cell moved
        CGPoint translation = [panGesture translationInView:self.view];
        
        //if the cell was moved more than half the width of a cell then delete it
        if (translation.x &amp;gt; 160.0) {
            //get the indexPath of the cell that needs to be deleted
            CGPoint location = [panGesture locationInView:self.tableView];
            NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:location];
            
            //if a cell exists at this position then delete it
            if ([self.tableView cellForRowAtIndexPath:swipedIndexPath]) {
                [self.data removeObjectAtIndex:swipedIndexPath.row];

                UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];
                
                [UIView animateWithDuration:0.3
                                 animations:^{cell.frame = CGRectMake(cell.frame.size.width, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height);}
                                 completion:^(BOOL finished){[self.tableView deleteRowsAtIndexPaths:@[swipedIndexPath]
                                                                                   withRowAnimation:UITableViewRowAnimationAutomatic];
                                 }];
                
            }
        }
        //cell was not moved more than 160 points then snap back to position
        else {
            CGPoint location = [panGesture locationInView:self.tableView];
            NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:location];
        
            UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];
            cell.backgroundColor = [UIColor whiteColor];
            [UIView animateWithDuration:0.3
                             animations:^{cell.frame = CGRectMake(0.0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height);}
                             completion:^(BOOL finished){}];
        }
        
    }
    // if the user is still dragging the cell
    else if (panGesture.state == UIGestureRecognizerStateChanged) {
        CGPoint translation = [panGesture translationInView:self.view];
        CGPoint location = [panGesture locationInView:self.tableView];
        NSIndexPath *swipedIndexPath = [self.tableView indexPathForRowAtPoint:location];
        
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:swipedIndexPath];
        
        //if the draggin was to the right then change the background color to red and move the cell
        if (cell &amp;amp;&amp;amp; translation.x &amp;gt; 0) {
            cell.backgroundColor = [UIColor redColor];
            [UIView animateWithDuration:0.1
                             animations:^{cell.frame = CGRectMake(translation.x, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height);}
                             completion:^(BOOL finished){}];
        }
    }
}&lt;/code&gt;&lt;/pre&gt;
Finally, we need to implement one delegate methods - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer  If we are dragging vertically we want   the table view to handle it so it can scroll the rows.  Therefore we check that the x translation is bigger than the y translation.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
        CGPoint translation = [(UIPanGestureRecognizer*)gestureRecognizer translationInView:self.view.superview];
        if (fabsf(translation.x) &amp;gt; fabsf(translation.y)) {
            return YES;
        }
        return NO;
    }
    return YES;
}&lt;/code&gt;&lt;/pre&gt;
At this point you should be able to run (command+R) the project and delete rows by dragging them offscreen.


&lt;br /&gt;
&lt;br /&gt;
You can download the source code for this project from &lt;a href=&quot;https://github.com/code-and-coffee/DeleteCellsByDraggingOffscreen.git&quot; target=&quot;_blank&quot;&gt;github&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/8752180497928905044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/01/how-to-delete-uitableviewcells-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8752180497928905044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8752180497928905044'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/01/how-to-delete-uitableviewcells-in.html' title='How to Delete UITableViewCells in a UITableView by Dragging Them Offscreen Using UIPanGestureRecognizer iOS7.'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipU9cmRHhya1LgYDQdaHJjZ1YbqUTSZpoCpXdGpeJLcGaydPyYBCzAQCgxZ6sBMLBGC_ff6KcOb6zTQw5Kxh62zbWONXNHWUYcDHGj_iYthfRB2A4qkJumu1aBIeqpbrWocOiR0u9_aqo/s72-c/23_add_tableViewController_to_storyboard.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-6912433699831150738</id><published>2014-01-07T11:45:00.000-08:00</published><updated>2014-02-02T13:28:16.691-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Getting Started with iOS 7.</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 19px;&quot;&gt;This is a &quot;Hello World&quot; tutorial to iOS programming. &amp;nbsp;We are going to build an iPhone app that has a counter and two buttons. &amp;nbsp;Tapping the &quot;+1&quot; button increments the counter and tapping &quot;-1&quot; decrements the counter.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 19px;&quot;&gt;Open Xcode and start a new project File-&amp;gt;New-&amp;gt;Project. &amp;nbsp;Under iOS templates select Application and then &quot;Single View Application&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht2GZiSpVdFjwd4tr9djz4b0SMJ1ye9ffK6Jzti4eY6i-S-uoAEC_09qTzoH79feoFKCD2-dWhfshNVlafPx4S_RhRYCV4KxWlcg3Z36Y8hn1MvyynFc9Ami1zByrsO9ka9IwvGXRunjQ/s1600/22_start_single_view_app.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht2GZiSpVdFjwd4tr9djz4b0SMJ1ye9ffK6Jzti4eY6i-S-uoAEC_09qTzoH79feoFKCD2-dWhfshNVlafPx4S_RhRYCV4KxWlcg3Z36Y8hn1MvyynFc9Ami1zByrsO9ka9IwvGXRunjQ/s1600/22_start_single_view_app.png&quot; height=&quot;430&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #333333; font-family: Helvetica Neue Light, HelveticaNeue-Light, Helvetica Neue, Helvetica, Arial, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px;&quot;&gt;Click on &quot;Next&quot; and choose the options for the project. &amp;nbsp;Type in &quot;Counter&quot; for Product Name and Class Prefix. &amp;nbsp;Company Identifier can be anything, so put your company name or n/a. &amp;nbsp;Select iPhone for Device Family.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCGY7VL1c54hZNPMAwDAMwdpF4TiHGaUcixuxHu_ydb3Tts2jrmwv45zIWXK0g3E2utFpIqrAsNXpoKmseg4c8BEDokIsKlm1j6Yi6-cBYDNkUS4MD-gJANDnRnfCGaiAT6aIw-RqkJeI/s1600/22_save_new_project.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCGY7VL1c54hZNPMAwDAMwdpF4TiHGaUcixuxHu_ydb3Tts2jrmwv45zIWXK0g3E2utFpIqrAsNXpoKmseg4c8BEDokIsKlm1j6Yi6-cBYDNkUS4MD-gJANDnRnfCGaiAT6aIw-RqkJeI/s1600/22_save_new_project.png&quot; height=&quot;430&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;Click Next to save your new project. &amp;nbsp;Xcode should have created 5 different files for you:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;1) CounterAppDelegate.h&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;2) CounterAppDelegate.m&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;3) MainStoryboard.storyboard&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;4) CounterViewController.h&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;5) CounterViewController.m&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot; /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;We will make changes to the the last 3 files in this project.&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot; /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;Open MainStoryboard.storyboard.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCoVHLxxN-Ivq8HqdzazoA-2ocTWp9CPGmM8ltB5QIbFVbgoSAqV3mCdc77h4KclEpv9FnLAgtNx-C8PuZizVuMn0C9cUbpqI2pyBAyVj4XzpuUYZFlbrno8-yAVfNpWos9Rqy7YQVdOM/s1600/22_mainstoryboard.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCoVHLxxN-Ivq8HqdzazoA-2ocTWp9CPGmM8ltB5QIbFVbgoSAqV3mCdc77h4KclEpv9FnLAgtNx-C8PuZizVuMn0C9cUbpqI2pyBAyVj4XzpuUYZFlbrno8-yAVfNpWos9Rqy7YQVdOM/s1600/22_mainstoryboard.png&quot; height=&quot;394&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;In the lower right corner is the Object Library. &amp;nbsp;From the Object Library drag two &quot;Buttons&quot; and a &quot;Label&quot; to the canvas. &amp;nbsp;Double click on the buttons and on the label and change their titles to the following.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTrCkssq3wX9ptbjNfK_Yr-OD0SD_pC7G9AQ_5yy1eZJBFcebKkY882_ikJB104c-Yrld103914upIxg1TcmEHzUa5FMwU0oxQ-XyxaGlO-l-Vu8W7WITvPMnYrBnnWiHnHEYBvvV7EwA/s1600/22_add_buttons.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTrCkssq3wX9ptbjNfK_Yr-OD0SD_pC7G9AQ_5yy1eZJBFcebKkY882_ikJB104c-Yrld103914upIxg1TcmEHzUa5FMwU0oxQ-XyxaGlO-l-Vu8W7WITvPMnYrBnnWiHnHEYBvvV7EwA/s1600/22_add_buttons.png&quot; height=&quot;640&quot; width=&quot;442&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;Now we need to create outlets and actions to connect our buttons to the code. &amp;nbsp;There are a few different ways to create actions and outlets in Xcode. &amp;nbsp;The easiest one is to click on the assistance editor button.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB1wsCMzlB4dtEXlZqne2l3JVEmKT-1oxp3bG3n9agXctn_cgc4iBI7VZsC3usjeaL0AUzOz38egOHCVh6DNOxTkege_YawIa_8kfhhodIqLlJs7Mbt08WP4kLlNJDtfbhIDBL7ObUUqg/s1600/22_assistance_editor_button.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB1wsCMzlB4dtEXlZqne2l3JVEmKT-1oxp3bG3n9agXctn_cgc4iBI7VZsC3usjeaL0AUzOz38egOHCVh6DNOxTkege_YawIa_8kfhhodIqLlJs7Mbt08WP4kLlNJDtfbhIDBL7ObUUqg/s1600/22_assistance_editor_button.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;This will open CounterViewController.h to the right of the storyboard. &amp;nbsp;Click ctrl and drag from each button to the area between @property and @end in the CounterViewController.h file. &amp;nbsp;A pop up will appear, select Connection=action and set Name=decrement for the &quot;-1&quot; button and Name=increment for &quot;+1&quot; button. &amp;nbsp;Press Connect to create the action.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigZuMYyrqPF7SMnGFhnuUcBqLz9VHU427Co6CsfbI9EVIREzHTsAsJlh4B9EhNM8N5uruiyVnSRX2va3Y95nDcr1T5a5THAgv2zc06To_6XUiLEF9EMqHAUOvRoWEBXaU6_pTX-SUh04M/s1600/22_set_action.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigZuMYyrqPF7SMnGFhnuUcBqLz9VHU427Co6CsfbI9EVIREzHTsAsJlh4B9EhNM8N5uruiyVnSRX2va3Y95nDcr1T5a5THAgv2zc06To_6XUiLEF9EMqHAUOvRoWEBXaU6_pTX-SUh04M/s1600/22_set_action.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #333333; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;Do the same for the label but set Connection=outlet and Name=label. &amp;nbsp;We also need to add a counter to keep track of our value. &amp;nbsp;Again in CounterViewController.h under @interface add the following code &quot;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #cd00a6; font-family: Menlo; font-size: 13px;&quot;&gt;@property&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #cd00a6; font-family: Menlo; font-size: 13px; text-align: justify;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #cd00a6; font-family: Menlo; font-size: 13px; text-align: justify;&quot;&gt;nonatomic&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #cd00a6; font-family: Menlo; font-size: 13px; text-align: justify;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #cd00a6; font-family: Menlo; font-size: 13px; text-align: justify;&quot;&gt;int&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #cd00a6; font-family: &#39;Helvetica Neue Light&#39;, HelveticaNeue-Light, &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Menlo; font-size: xx-small;&quot;&gt;counter;&quot; &amp;nbsp;&lt;/span&gt;After adding all this CounterViewController.h should look like similar to this.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
@interface CounterViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *label;
@property int counter;
- (IBAction)increment:(id)sender;
- (IBAction)decrement:(id)sender;

@end&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
Open CounterViewController.m find the decrement and increment methods and implement them.  They should look like the following when done.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
- (IBAction)decrement:(id)sender {
    self.counter -= 1;
    [self.label setText:[NSString stringWithFormat:@&quot;%d&quot;, self.counter]];
}
- (IBAction)increment:(id)sender {
    self.counter += 1;
    [self.label setText:[NSString stringWithFormat:@&quot;%d&quot;, self.counter]];
}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
The app is ready to run.  Go to Product-&amp;gt;Run and wait for the sumulator to load. Every time you press +1 button the number in the label increases by 1, pressing -1 button decreases the counter by 1.
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLYG_ptqLJB7wAGCcJG9MrvelcEYx1pIvBswvc_M_cd5cGNCelzG79UiGVfRo5Ge5JwM3tYU9HjYnJL8dmzNcyeMx4WOAsjM9ovwB69ORzPSLok7MAPkpVy45NFgM0qCMA8b5vNDD7R34/s1600/22_app_running.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLYG_ptqLJB7wAGCcJG9MrvelcEYx1pIvBswvc_M_cd5cGNCelzG79UiGVfRo5Ge5JwM3tYU9HjYnJL8dmzNcyeMx4WOAsjM9ovwB69ORzPSLok7MAPkpVy45NFgM0qCMA8b5vNDD7R34/s1600/22_app_running.png&quot; height=&quot;640&quot; width=&quot;426&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/6912433699831150738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/01/getting-started-with-ios-7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/6912433699831150738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/6912433699831150738'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/01/getting-started-with-ios-7.html' title='Getting Started with iOS 7.'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEht2GZiSpVdFjwd4tr9djz4b0SMJ1ye9ffK6Jzti4eY6i-S-uoAEC_09qTzoH79feoFKCD2-dWhfshNVlafPx4S_RhRYCV4KxWlcg3Z36Y8hn1MvyynFc9Ami1zByrsO9ka9IwvGXRunjQ/s72-c/22_start_single_view_app.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-2998315703206452914</id><published>2014-01-07T11:01:00.000-08:00</published><updated>2014-02-02T13:27:58.635-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="core data"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="programm"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>How to Debug Core Data Apps.</title><content type='html'>If you are developing an app that takes advantage of core data storage, it is hard to debug it since there is no way to see what data is store in the database from Xcode. &amp;nbsp;There are varies apps that you can install that would let you see what is being store by core data, but most of them cost money. &amp;nbsp;Thankfully, there is a free solution. &amp;nbsp;Mac OS X already comes with sqlite3 (command line interface for SQLite.)&lt;br /&gt;
&lt;br /&gt;
When you want to debug your app just run it in the iOS simulator. &amp;nbsp;After that open the Terminal and run the sqlite3 command with the file name of the sqlite db that stores the data. &amp;nbsp; It is usually inside your home directory and then&amp;nbsp;/Library/Application Support/iPhone Simulator/7.0.3 (iOS simulator version)/Applications/ find your app in the Applications directory and then in the Documents folder there is a file with the name of your app and extension .sqlite&lt;br /&gt;
&lt;br /&gt;
I have an app called Invoicer so I would run the following command in the terminal.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Menlo; font-size: 14px;&quot;&gt;
&lt;pre&gt;&lt;code&gt;sqlite3 ~/Library/Application\ Support/iPhone\ Simulator/7.0.3/Applications/99E6F8E3-FC00-4018-9D84-F309984FB010/Documents/Invoicer.sqlite
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Menlo; font-size: 14px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
I can view all the tables available with the .tables command

&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Menlo; font-size: 14px;&quot;&gt;
sqlite&amp;gt; .tables&lt;/div&gt;
&lt;div style=&quot;font-family: Menlo; font-size: 14px;&quot;&gt;
ZPROJECT&amp;nbsp; &amp;nbsp; &amp;nbsp; ZTIMER&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Z_METADATA&amp;nbsp; &amp;nbsp; Z_PRIMARYKEY&lt;/div&gt;
&lt;br /&gt;
I can view the content of a particular table with the select command.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Menlo; font-size: 14px;&quot;&gt;
sqlite&amp;gt; select * from ZPROJECT;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
Consult the sqlite documentation for other queries you can perform to explore the database Core Data created. &lt;br /&gt;
&lt;br /&gt;
You can exit with&amp;nbsp;&lt;span style=&quot;font-family: Menlo; font-size: 14px;&quot;&gt;sqlite&amp;gt; .quit&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Menlo; font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;

Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/2998315703206452914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/01/how-to-debug-core-data-apps.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/2998315703206452914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/2998315703206452914'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/01/how-to-debug-core-data-apps.html' title='How to Debug Core Data Apps.'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-6245725219081386787</id><published>2014-01-06T04:24:00.000-08:00</published><updated>2014-02-02T13:27:42.636-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Custom Fonts"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="UIFont"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>How to Use Custom Fonts in iOS Apps.</title><content type='html'>If you need to use a custom font that is not available in iOS, you need to do the following steps.&lt;br /&gt;
1) Import the fonts into the Xcode project.&lt;br /&gt;
2) Add the fonts to the plist file.&lt;br /&gt;
3) Start using them in your app.&lt;br /&gt;
&lt;br /&gt;
Open your project in Xcode and drag and drop the fonts that you need to use into the project navigator. &amp;nbsp;I usually put them in a group called resources. &amp;nbsp;Make sure that &quot;Copy items into destination group&#39;s folder&quot; is checked and that &quot;Add to targets&quot; is also checked for the appropriate target.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZwBm39GNgvZv7legKPxu6I7X1g8W868K0dgIwddCGKBv6ldw_Y7_8QOhIyVLkooeAbnxqlmG5HgiHZfCIHkbwdjO2yHFbUnoumG3pB2hyf_HgfKpg8NxR510mngo3tRbAZT1RiHLsNu0/s1600/20_adding_fonts_to_xcode.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZwBm39GNgvZv7legKPxu6I7X1g8W868K0dgIwddCGKBv6ldw_Y7_8QOhIyVLkooeAbnxqlmG5HgiHZfCIHkbwdjO2yHFbUnoumG3pB2hyf_HgfKpg8NxR510mngo3tRbAZT1RiHLsNu0/s1600/20_adding_fonts_to_xcode.png&quot; height=&quot;432&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The next step is to add the font to the plist file. &amp;nbsp;Open your app info.plist file. &amp;nbsp;It should be called &quot;app name&quot;-info.plist and it is usually under Supporting Files. &amp;nbsp;Add a new row called &quot;Fonts provided by application&quot; it should be an array. &amp;nbsp;Then add the file names of your fonts as string members of the array. &amp;nbsp;My font is called Calibre-medium.ttf&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAXQXV4ES9HwepQafLcBW_ogmbL6-og6oalirNCWK0nC_oGRLswodbcvnMewkyXYDhRysW3VPcHPWMlxrnX_ap9YksuL1DRNTbgrim68SCRJkLyty3Yhij21oHjUjufAo7TnR5psaOKFI/s1600/20_adding_fonts_to_plist.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAXQXV4ES9HwepQafLcBW_ogmbL6-og6oalirNCWK0nC_oGRLswodbcvnMewkyXYDhRysW3VPcHPWMlxrnX_ap9YksuL1DRNTbgrim68SCRJkLyty3Yhij21oHjUjufAo7TnR5psaOKFI/s1600/20_adding_fonts_to_plist.png&quot; height=&quot;364&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
At this point you are ready to use the font in your app.&lt;br /&gt;
&lt;br /&gt;
For example if you have a UILabel *myLabel you can use the font with:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;myLabel.font = [UIFont fontWithName:@&quot;Calibre-medium&quot; size:16];&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/6245725219081386787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2014/01/how-to-use-custom-fonts-in-ios-apps.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/6245725219081386787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/6245725219081386787'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2014/01/how-to-use-custom-fonts-in-ios-apps.html' title='How to Use Custom Fonts in iOS Apps.'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZwBm39GNgvZv7legKPxu6I7X1g8W868K0dgIwddCGKBv6ldw_Y7_8QOhIyVLkooeAbnxqlmG5HgiHZfCIHkbwdjO2yHFbUnoumG3pB2hyf_HgfKpg8NxR510mngo3tRbAZT1RiHLsNu0/s72-c/20_adding_fonts_to_xcode.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-7500532436937828352</id><published>2013-12-15T22:59:00.003-08:00</published><updated>2014-03-18T18:03:15.975-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="UIBarButtonItem"/><category scheme="http://www.blogger.com/atom/ns#" term="UINavigationBar"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Adding Multiple Bar Button Items to a Navigation Bar</title><content type='html'>Sometimes you want to add more than one barButtonItem to the navigation bar of your application on either the left or the right side. &amp;nbsp;Unfortunately, this cannot be done by dragging the buttons in Xcode and dropping them on the navigation bar. &amp;nbsp;This must be done in code.&lt;br /&gt;
&lt;br /&gt;
Start a new &quot;single view&quot; application in Xcode. &amp;nbsp;Open Main.storyboard, select view controller and then embed it in a Navigation Controller. &amp;nbsp;This is done by clicking on (Editor-&amp;gt;Embed In-&amp;gt;Navigation Controller)&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiXHcTMeoQULnEm3oZ6MgAWH1UeIZ2O0OdpJ1c8fQsT3MwUJh-8P6xjVabXa8GjvsB5OQngw6cThG8vhcSvsY1BSzQ5hyphenhyphen9t3Jte1_FPJ8yklsvM7XYdUyWFE9UGBf-fw3HE6nAk1wTBiE/s1600/19_embed_in_navigation_controller.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiXHcTMeoQULnEm3oZ6MgAWH1UeIZ2O0OdpJ1c8fQsT3MwUJh-8P6xjVabXa8GjvsB5OQngw6cThG8vhcSvsY1BSzQ5hyphenhyphen9t3Jte1_FPJ8yklsvM7XYdUyWFE9UGBf-fw3HE6nAk1wTBiE/s640/19_embed_in_navigation_controller.png&quot; height=&quot;254&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
We will add the buttons in ViewController.m inside the viewDidLoad method. &amp;nbsp;Declare and initialize two UIBarButtonItems. &amp;nbsp;One of them will be an edit button and the other one will be a save button. &amp;nbsp;The target will be self and the action will be methods that you will need to implement to do whatever you need them to do when the buttons are clicked.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;UIBarButtonItem *editBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editAction)];
    
UIBarButtonItem *saveBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(saveAction)];
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
Finally, we need to add the buttons to the navigation bar.  
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;self.navigationItem.rightBarButtonItems = [[NSArray alloc] initWithObjects:editBarButtonItem, saveBarButtonItem, nil];
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
This is what your viewDidLoad should look like at this point.

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIBarButtonItem *editBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editAction)];
    
    UIBarButtonItem *saveBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(saveAction)];
    
    self.navigationItem.rightBarButtonItems = [[NSArray alloc] initWithObjects:editBarButtonItem, saveBarButtonItem, nil];   
}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
We also need to implement the methods editAction and saveAction.

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
-(void)editAction
{
    NSLog(@&quot;edit button clicked&quot;);
}

-(void)saveAction
{
    NSLog(@&quot;save button clicked&quot;);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
At this point you can run the app and see that the two buttons are added to the navigation bar.  Clicking on them prints the log messages to the console.

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO3N_CJBg_kYS3iJYQY-zNPKrVeUkZKhrlRea9Fat5fuWhvu-d2Ya7uyEieHSbrOGFC76v4OY4-12lAXJG_rMGXJ4KdaETUwdl3HS4mZVx3SHunwfWvmf7JbKBrFymW-ylOAH0ZNEenp8/s1600/19_simulator_screen.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO3N_CJBg_kYS3iJYQY-zNPKrVeUkZKhrlRea9Fat5fuWhvu-d2Ya7uyEieHSbrOGFC76v4OY4-12lAXJG_rMGXJ4KdaETUwdl3HS4mZVx3SHunwfWvmf7JbKBrFymW-ylOAH0ZNEenp8/s640/19_simulator_screen.png&quot; height=&quot;640&quot; width=&quot;426&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;br /&gt;
&lt;div&gt;
&lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/7500532436937828352/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/12/adding-multiple-bar-button-items-to.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/7500532436937828352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/7500532436937828352'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/12/adding-multiple-bar-button-items-to.html' title='Adding Multiple Bar Button Items to a Navigation Bar'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiXHcTMeoQULnEm3oZ6MgAWH1UeIZ2O0OdpJ1c8fQsT3MwUJh-8P6xjVabXa8GjvsB5OQngw6cThG8vhcSvsY1BSzQ5hyphenhyphen9t3Jte1_FPJ8yklsvM7XYdUyWFE9UGBf-fw3HE6nAk1wTBiE/s72-c/19_embed_in_navigation_controller.png" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-7165572747650504487</id><published>2013-07-22T09:41:00.000-07:00</published><updated>2014-02-02T13:27:09.377-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Using Breakpoints for Logging.</title><content type='html'>Many developers use NSLog() for logging to the console. &amp;nbsp;There is an easier way to do the same using breakpoints. &amp;nbsp;When you use NSLog(), you have to go through your code and comment out each line that is printing to the console if you want to disable logging. &amp;nbsp;It is much easier to disable all breakpoints at the same time.&lt;br /&gt;
&lt;br /&gt;
To create a breakpoint, click in the gutter next to the line you are interested in. &amp;nbsp;Then right-click on the breakpoint and click on &lt;i&gt;Edit Breakpoint... &amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd3CoNVUYTotHGu61ytLaycLhSYtK4E0kWCYFU8bhVCWvjKF20rpqMeuoeNxawEKcCN1dlK2wG-WOq1NYURxL863vqnZSghuG5MGp8pG4Zqps4IX_iy1zFj99dfBZ9-mhmSZvNw57oYKs/s1600/18_edit_breakpoint.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd3CoNVUYTotHGu61ytLaycLhSYtK4E0kWCYFU8bhVCWvjKF20rpqMeuoeNxawEKcCN1dlK2wG-WOq1NYURxL863vqnZSghuG5MGp8pG4Zqps4IX_iy1zFj99dfBZ9-mhmSZvNw57oYKs/s1600/18_edit_breakpoint.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
After that click on the&lt;i&gt; Add Action &lt;/i&gt;button.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-0-JG26ANTPPGxumHxlrd-t-UT2utQLooLdQTOHi0BqQP2uugjXNQxuNFK8Fv3KYdjLrdV5F2hGiyHI51RKBR6IBiepGS4dOnTdH5i_aGHYQKtOcSHq4xDW_ZOfymkcfAvsKc6i3bHXY/s1600/18_add_action.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-0-JG26ANTPPGxumHxlrd-t-UT2utQLooLdQTOHi0BqQP2uugjXNQxuNFK8Fv3KYdjLrdV5F2hGiyHI51RKBR6IBiepGS4dOnTdH5i_aGHYQKtOcSHq4xDW_ZOfymkcfAvsKc6i3bHXY/s1600/18_add_action.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
You can add as many actions as you need with the + and - buttons. &amp;nbsp;For example you can add a log message &quot;my method called&quot;. &amp;nbsp;Then you can add a debugger command that prints the values of some of your variables in that method. &amp;nbsp;In most cases you would want to check the option &lt;i&gt;Automatically continue after evaluation&lt;/i&gt;. &amp;nbsp;This will not stop your app when the breakpoint is reached.&lt;br /&gt;
&lt;br /&gt;
To give you an example. &amp;nbsp;I have created a single view application. &amp;nbsp;In the viewDidLoad: method I have &amp;nbsp;declared an NSString *myString. &amp;nbsp;If I want to log when that particular method is called and print the value of the string I will need to set up a breakpoint with the following actions.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4uqoipsCF7Abys55I1JoK9KK9KVNFBlHsvu3Ys5_nsMBG2dh0bk6BTi2HfZrzNa9io1GD6JY2WSzzSIWiMnZ36wDzux6KH3Cp5WoSwA2PjfXW0Kwtl9rqOWpGLjeLeVcXtKKhRawKWzc/s1600/18_example.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4uqoipsCF7Abys55I1JoK9KK9KVNFBlHsvu3Ys5_nsMBG2dh0bk6BTi2HfZrzNa9io1GD6JY2WSzzSIWiMnZ36wDzux6KH3Cp5WoSwA2PjfXW0Kwtl9rqOWpGLjeLeVcXtKKhRawKWzc/s1600/18_example.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Consult the &lt;a href=&quot;http://lldb.llvm.org/index.html&quot; target=&quot;_blank&quot;&gt;LLDB debugger documentation&lt;/a&gt; to see what can be done with the debugger command.&lt;br /&gt;
&lt;br /&gt;
To disable or enable all the breakpoints in your project. &amp;nbsp;Go to the Breakpoint Navigator (command+6), right-click on the project name and disable or enable the breakpoints.&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/7165572747650504487/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/07/using-breakpoints-for-logging.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/7165572747650504487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/7165572747650504487'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/07/using-breakpoints-for-logging.html' title='Using Breakpoints for Logging.'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjd3CoNVUYTotHGu61ytLaycLhSYtK4E0kWCYFU8bhVCWvjKF20rpqMeuoeNxawEKcCN1dlK2wG-WOq1NYURxL863vqnZSghuG5MGp8pG4Zqps4IX_iy1zFj99dfBZ9-mhmSZvNw57oYKs/s72-c/18_edit_breakpoint.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-4675143626181246062</id><published>2013-07-17T10:30:00.001-07:00</published><updated>2014-02-02T13:26:51.886-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Core Animation"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="iphone"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Introduction to Core Animation.</title><content type='html'>&lt;br /&gt;
Core Animation is an API that can be used to animate the views in your app. &amp;nbsp; &amp;nbsp;Let&#39;s make an app that has an image that we move around on the screen. &amp;nbsp;We are going to accomplish this buy using CALayer class, which can be used to animate image based content. &lt;br /&gt;
&lt;br /&gt;
Start a new iOS Single View Application project in Xcode. &amp;nbsp;Select iPhone device in the drop-down menu. &amp;nbsp;We want to use storyboards and ARC in this project so make sure &lt;i&gt;use storyboards&lt;/i&gt; and &lt;i&gt;use automatic reference counting&lt;/i&gt; are checked. &amp;nbsp;Give it a name and save the project.&lt;br /&gt;
&lt;br /&gt;
CALayer is part of the quartz framework, so we need to add the QuartzCore framework to our project. &amp;nbsp;If you don&#39;t know how to do this, it is explained in this &lt;a href=&quot;http://code-and-coffee.blogspot.com/2012/09/how-to-add-frameworks-in-xcode-4.html&quot; target=&quot;_blank&quot;&gt;tutorial&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Open ViewController.m and at the top import the quartz framework #import &amp;lt;QuartzCore/QuartzCore.h&amp;gt; &amp;nbsp;Find an image that you want to use in your animation and drag it to Xcode. &amp;nbsp;The name of my image is Sunshine.png, if you use a different name make the appropriate changes in your code.&lt;br /&gt;
&lt;br /&gt;
Time to implement the viewDidLoad: method. &amp;nbsp;First we declare a UIImageView, setting its frame and adding it as a subview.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
- (void)viewDidLoad
{
    [super viewDidLoad];

    UIImageView *sun = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@&quot;Sunshine&quot;]];
   
    [sun setFrame:CGRectMake(10.0, 10.0, 60.0, 60.0)];
   
    [self.view addSubview:sun];
}
&lt;/code&gt;&lt;/pre&gt;
If you run the app, you should be getting the following results:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGXGUjvUZfOHJgYF4-cdCPdgPp2xhqSmcNxE6l3WFn7FPMrkFFYcvTCeotTaTBNmuiqXTPmFGeMRwtRpXn1_jHre6pD45t9aOcpIaHORTuOgc_L5Z280RBL1Eg_seNC6Y631yKRf6Ouxs/s1600/16_iOSSimulatorScreenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGXGUjvUZfOHJgYF4-cdCPdgPp2xhqSmcNxE6l3WFn7FPMrkFFYcvTCeotTaTBNmuiqXTPmFGeMRwtRpXn1_jHre6pD45t9aOcpIaHORTuOgc_L5Z280RBL1Eg_seNC6Y631yKRf6Ouxs/s400/16_iOSSimulatorScreenshot.png&quot; width=&quot;266&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
To implement the animation we need to declare a CABasicAnimation, set the fromValue, toValue, and duration. &amp;nbsp;We also need to set the layer position to the toValue, otherwise the image will jump to its starting point when he animation completes. &amp;nbsp;And finally, we need to add the animation to the UIImageView layer.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
We add the necessary changes to viewDidLoad:&lt;/div&gt;
&lt;pre&gt;&lt;code&gt;- (void)viewDidLoad
{
    [super viewDidLoad];

    UIImageView *sun = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@&quot;Sunshine&quot;]];
   
    [sun setFrame:CGRectMake(10.0, 10.0, 60.0, 60.0)];
   
    [self.view addSubview:sun];
   
    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@&quot;position&quot;];
    animation.fromValue = [NSValue valueWithCGPoint:sun.layer.position];
    animation.toValue = [NSValue valueWithCGPoint:CGPointMake(250.0f, 250.0f)];
    animation.duration = 5.0f;
    sun.layer.position = CGPointMake(250.0f, 250.0f);
    [sun.layer addAnimation:animation forKey:@&quot;AnimateFrame&quot;];  
}
&lt;/code&gt;&lt;/pre&gt;
Run the app and you should see the image animate from the 10x10 point to the 250x250 point in 5 seconds.&lt;br /&gt;
&lt;br /&gt;
Core Animation is very complicated topic, check the &lt;a href=&quot;https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html&quot; target=&quot;_blank&quot;&gt;Core Animation Programming Guide&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/4675143626181246062/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/07/introduction-to-core-animation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/4675143626181246062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/4675143626181246062'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/07/introduction-to-core-animation.html' title='Introduction to Core Animation.'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGXGUjvUZfOHJgYF4-cdCPdgPp2xhqSmcNxE6l3WFn7FPMrkFFYcvTCeotTaTBNmuiqXTPmFGeMRwtRpXn1_jHre6pD45t9aOcpIaHORTuOgc_L5Z280RBL1Eg_seNC6Y631yKRf6Ouxs/s72-c/16_iOSSimulatorScreenshot.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-5537650772285769559</id><published>2013-07-12T05:21:00.003-07:00</published><updated>2014-02-02T13:26:35.437-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Core Graphics"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS 6"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Introduction to Core Graphics and Drawing with Quartz 2D: Drawing Shapes Using Bezier Paths</title><content type='html'>&lt;br /&gt;
You can use bezier paths to draw squares, circles, arcs, and even more complex shapes.&lt;br /&gt;
&lt;br /&gt;
Start a new iOS Single View Application project in Xcode. &amp;nbsp;Select iPhone device in the drop-down menu. &amp;nbsp;We want to use storyboards and ARC in this project so make sure &lt;i&gt;use storyboards&lt;/i&gt; and &lt;i&gt;use automatic reference counting&lt;/i&gt; are checked. &amp;nbsp;Give it a name and save the project.&lt;br /&gt;
&lt;br /&gt;
Custom drawing is done in the drawRect: method defined in the UIView class. &amp;nbsp;So we need to subclass UIView and add all our drawing code to the drawRect: method. &amp;nbsp;Create a new Objective-C class (command+N). &amp;nbsp;Name it CustomView and subclass from UIView.&lt;br /&gt;
&lt;br /&gt;
Next, we need to change the class of the ViewController&#39;s view property &amp;nbsp;from UIView to our CustomView class. &amp;nbsp;Open MainStoryboard.storyboard and in the document outline click on View icon. &amp;nbsp;Then, open the identity inspector (option+command+3) and change to class name to CustomView.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-HWZey0OCzWgKNDsUhOX02eoPKjMD3W8pR57_ilYxiseAKvvQ-dA6JBuZYTTUh3ZeDO-s6cgPwJ2yOxkRubVjZ9Jrt5xukK7aJ9Q_v5GSpA6R9mxZoeehc2f9crPznYuJsDXmbFNZOpQ/s1600/16_change_view_class.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;388&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-HWZey0OCzWgKNDsUhOX02eoPKjMD3W8pR57_ilYxiseAKvvQ-dA6JBuZYTTUh3ZeDO-s6cgPwJ2yOxkRubVjZ9Jrt5xukK7aJ9Q_v5GSpA6R9mxZoeehc2f9crPznYuJsDXmbFNZOpQ/s640/16_change_view_class.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
There are a number or steps that need to be taken to be able to draw shapes with bezier paths. &amp;nbsp;First we need to create the UIBezierPath object. &amp;nbsp;Then we need to set the starting point with the moveToPoint: method. &amp;nbsp;After this we need to add the lines that create the path with the addLineToPoint: method. &amp;nbsp; At the end, if we want, we can close the path with the closePath: method that draws a line to the starting point. &amp;nbsp; &amp;nbsp;Before we draw, we also need to set the line width and stroke color. &amp;nbsp;At the end, we stroke the path with the stoke: method. &lt;br /&gt;
&lt;br /&gt;
Let&#39;s draw something random using bezier paths. &amp;nbsp;Open CustomView.m and implement the following code.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;- (void)drawRect:(CGRect)rect
{
    //declare and instantiate the UIBezierPath object
    UIBezierPath *aPath = [UIBezierPath bezierPath];
   
    // Set the starting point of the shape.
    [aPath moveToPoint:CGPointMake(100.0, 100.0)];
   
    // Draw some lines.
    [aPath addLineToPoint:CGPointMake(200.0, 200.0)];
    [aPath addLineToPoint:CGPointMake(200.0, 300.0)];
    [aPath addLineToPoint:CGPointMake(250.0, 330.0)];
    [aPath addLineToPoint:CGPointMake(20.0, 400.0)];
    [aPath closePath];
   
    //set the line width
    aPath.lineWidth = 15;
   
    //set the stoke color
    [[UIColor greenColor] setStroke];
   
    //draw the path
    [aPath stroke];
}
&lt;/code&gt;&lt;/pre&gt;
If we run the app at this point, you should be getting the following result:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCjoQh5EoA798xn_mQ6e2z7-_mzclhbdRqu4YASu8vfAyBSVz07lYHsCeu48odOBAl2x1KAfa_xkBIGLA5buzUlxhL6gkNKXrpDeBd0QfZquXGbUbikw-A86dbbJYT4if5nEhf4TopLaw/s1600/16_iOSSimulatorScreen.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCjoQh5EoA798xn_mQ6e2z7-_mzclhbdRqu4YASu8vfAyBSVz07lYHsCeu48odOBAl2x1KAfa_xkBIGLA5buzUlxhL6gkNKXrpDeBd0QfZquXGbUbikw-A86dbbJYT4if5nEhf4TopLaw/s400/16_iOSSimulatorScreen.png&quot; width=&quot;266&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
You can also fill the shape with color by setting the fill color with [[apath redColor] setFill]; and then draw it with [aPath fill]; Let&#39;s add this to our drawRect: method and see the changes.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
- (void)drawRect:(CGRect)rect
{
    //declare and instantiate the UIBezierPath object
    UIBezierPath *aPath = [UIBezierPath bezierPath];
    
    // Set the starting point of the shape.
    [aPath moveToPoint:CGPointMake(100.0, 100.0)];
    
    // Draw some lines.
    [aPath addLineToPoint:CGPointMake(200.0, 200.0)];
    [aPath addLineToPoint:CGPointMake(200.0, 300.0)];
    [aPath addLineToPoint:CGPointMake(250.0, 330.0)];
    [aPath addLineToPoint:CGPointMake(20.0, 400.0)];
    [aPath closePath];
    
    //set the line width
    aPath.lineWidth = 15;
    
    //set the stoke color
    [[UIColor greenColor] setStroke];
    [[UIColor redColor] setFill];

    
    //draw the path
    [aPath fill];
    [aPath stroke];
}
&lt;/code&gt;&lt;/pre&gt;
When we run the app, we get the following result.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdCaMjBX3II23RMOotMba7CAk37YCSi2Gg8UiewocyqJvCGlyx24_i0IxD-_W26Iw9xUqfWe3xR3JMIVGa2LSeaZXzijp5QrVIk1RHUwGk44qVf2go0FrgoBsbnYMOcZjO6JtVWH2Rzvg/s1600/16_iOSSimulatorScreen2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdCaMjBX3II23RMOotMba7CAk37YCSi2Gg8UiewocyqJvCGlyx24_i0IxD-_W26Iw9xUqfWe3xR3JMIVGa2LSeaZXzijp5QrVIk1RHUwGk44qVf2go0FrgoBsbnYMOcZjO6JtVWH2Rzvg/s400/16_iOSSimulatorScreen2.png&quot; width=&quot;266&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp;For more information check the documentation for UIBezierPath.&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/5537650772285769559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/07/introduction-to-core-graphics-and_12.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/5537650772285769559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/5537650772285769559'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/07/introduction-to-core-graphics-and_12.html' title='Introduction to Core Graphics and Drawing with Quartz 2D: Drawing Shapes Using Bezier Paths'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-HWZey0OCzWgKNDsUhOX02eoPKjMD3W8pR57_ilYxiseAKvvQ-dA6JBuZYTTUh3ZeDO-s6cgPwJ2yOxkRubVjZ9Jrt5xukK7aJ9Q_v5GSpA6R9mxZoeehc2f9crPznYuJsDXmbFNZOpQ/s72-c/16_change_view_class.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-8504728240196840176</id><published>2013-07-09T04:52:00.001-07:00</published><updated>2014-02-02T14:00:25.123-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Core Graphics"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="iphone"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Introduction to Core Graphics and Drawing with Quartz 2D: Drawing Lines</title><content type='html'>Start a new iOS &lt;i&gt;Single View Application&lt;/i&gt; project in Xcode. &amp;nbsp;Select &lt;i&gt;iPhone&lt;/i&gt; device in the&amp;nbsp;drop-down menu. &amp;nbsp;We want to use storyboards and ARC in this project so make sure&amp;nbsp;&lt;i&gt;use storyboards&lt;/i&gt; and use &lt;i&gt;automatic reference counting&lt;/i&gt; are checked. &amp;nbsp;Give it a name and save the project.&lt;br /&gt;
&lt;br /&gt;
Custom drawing is done in the drawRect: method defined in the UIView class. &amp;nbsp;So we need to subclass UIView and add all our drawing code to the drawRect: method. &amp;nbsp;Create a new Objective-C class (command+N). &amp;nbsp;Name it CustomView and subclass from UIView.&lt;br /&gt;
&lt;br /&gt;
Next, we need to change the class of the ViewController&#39;s view property &amp;nbsp;from UIView to our CustomView class. &amp;nbsp;Open MainStoryboard.storyboard and in the document outline click on View icon. &amp;nbsp;Then, open the identity inspector (option+command+3) and change to class name to CustomView.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUx5ELtmIaju2xeqdjHkihVsJKUT4b8oNsOKyc8mz1mFtc2Mp2YiH2-3EDQ20EtjXXIcVAVkEf_ZLy8u02tw8zz9TVo7ndDMhEfzd1JZVresqldwqS1q77bwubka5vsl11VJ-hTZVi-l8/s1600/15_change_view_class.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;388&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUx5ELtmIaju2xeqdjHkihVsJKUT4b8oNsOKyc8mz1mFtc2Mp2YiH2-3EDQ20EtjXXIcVAVkEf_ZLy8u02tw8zz9TVo7ndDMhEfzd1JZVresqldwqS1q77bwubka5vsl11VJ-hTZVi-l8/s640/15_change_view_class.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
We are ready to implement the drawRect: method. &amp;nbsp;Drawing in core graphics happens in a graphics context. &amp;nbsp;There are a number of steps that need to be taken to be able to draw a line. &amp;nbsp;The first thing we need to do is to retrieve the current context. &amp;nbsp;We do it with the following.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;CGContextRef currentContext = UIGraphicsGetCurrentContext();
&lt;/code&gt;&lt;/pre&gt;
After we get the graphics context we have to set the starting point. &amp;nbsp;We do this with &lt;i&gt;CGContextMoveToPoint. &amp;nbsp;&lt;/i&gt;Then we define where the end point will be with &lt;i&gt;CGContextAddLineToPoint.&lt;/i&gt;&amp;nbsp; We set the width of the line with&amp;nbsp;&lt;i&gt;CGContextSetLineWidth. &amp;nbsp;&lt;/i&gt;The color of the line is set with&amp;nbsp;&lt;i&gt;CGContextSetStrokeColorWithColor. &amp;nbsp;&lt;/i&gt;The last step is to stroke the path with&amp;nbsp;&lt;i&gt;CGContextStrokePath.&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
Let&#39;s implement the drawRect: method. &amp;nbsp;Open CustomView.m and add the following code.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;- (void)drawRect:(CGRect)rect
{
    //get the graphics context
    CGContextRef currentContext = UIGraphicsGetCurrentContext();
    
    //define starting point
    CGContextMoveToPoint(currentContext, 30.0, 60.0);
    
    //define end point
    CGContextAddLineToPoint(currentContext, 280.0, 280.0);
    
    //set line width
    CGContextSetLineWidth(currentContext, 15.0);
    
    //set the color
    CGContextSetStrokeColorWithColor(currentContext, [UIColor redColor].CGColor);
    
    //draw the line
    CGContextStrokePath(currentContext);
}&lt;/code&gt;&lt;/pre&gt;
Build and run the app.  This is the result you should be getting.

&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBKTbuoIJItTzgyB3Ql329dUYmCUamNLetwkO1GIc14Vog1HYjdkLGPpMJ_sdkz0xSKW-THxn870AtsVML5v_X_1fHEs5eXgykx87f_2uiAqDswgxqmYLAcSianbvoyQB2tw3UUJDQIq4/s1600/15_iOS+Simulator+Screen+shot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBKTbuoIJItTzgyB3Ql329dUYmCUamNLetwkO1GIc14Vog1HYjdkLGPpMJ_sdkz0xSKW-THxn870AtsVML5v_X_1fHEs5eXgykx87f_2uiAqDswgxqmYLAcSianbvoyQB2tw3UUJDQIq4/s400/15_iOS+Simulator+Screen+shot.png&quot; width=&quot;266&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/8504728240196840176/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/07/introduction-to-core-graphics-and.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8504728240196840176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8504728240196840176'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/07/introduction-to-core-graphics-and.html' title='Introduction to Core Graphics and Drawing with Quartz 2D: Drawing Lines'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUx5ELtmIaju2xeqdjHkihVsJKUT4b8oNsOKyc8mz1mFtc2Mp2YiH2-3EDQ20EtjXXIcVAVkEf_ZLy8u02tw8zz9TVo7ndDMhEfzd1JZVresqldwqS1q77bwubka5vsl11VJ-hTZVi-l8/s72-c/15_change_view_class.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-7605915643885993911</id><published>2013-05-17T15:52:00.001-07:00</published><updated>2014-02-02T14:00:13.388-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Creating iOS App Icons on the Cheap.</title><content type='html'>If you want to publish an app and don&#39;t have a lot of money to spend on an icon, you can use the sips (scriptable image processing system) command to resize an image and use it as an icon. &amp;nbsp;Find a creative commons&amp;nbsp;licensed&amp;nbsp;image (I use http://search.creativecommons.org/ to search for cc images) &amp;nbsp;Let&#39;s say your app has something to do with money or finance. &amp;nbsp;Search for an image that you can use. &amp;nbsp;I was able to find this image&amp;nbsp;http://pixabay.com/en/note-money-round-metal-penny-29871/ download the 1920 x 1920 image and save as money-image.png &lt;br /&gt;
&lt;br /&gt;
Open the terminal app and run the sips command:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&quot;sips --resampleWidth 57 money-image.png&amp;nbsp;--out Icon.png&quot;
&lt;/code&gt;&lt;/pre&gt;
Run the same command again, but this time change 57 to 114 for the retina display and output to
Icon@2x.png instead.&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&quot;sips --resampleWidth 114 money-image.png&amp;nbsp;--out Icon@2x.png&quot;
&lt;/code&gt;&lt;/pre&gt;
You can now use these in xCode as icons for your app. &amp;nbsp;Read the man page for sips to get more details and other options that you can use with this command.&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/7605915643885993911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/05/creating-ios-app-icons-on-cheap.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/7605915643885993911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/7605915643885993911'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/05/creating-ios-app-icons-on-cheap.html' title='Creating iOS App Icons on the Cheap.'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-222849936984899244</id><published>2013-03-10T06:13:00.001-07:00</published><updated>2014-02-02T14:00:02.528-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="ipad"/><category scheme="http://www.blogger.com/atom/ns#" term="iphone"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Introduction to Blocks and Multithreading in iOS</title><content type='html'>Blocks are important in iOS programming because they are used to implement multithreading with GCD (Grand Central Dispatch). &amp;nbsp;A block is a chunk of code contained in {}. &amp;nbsp;To indicate the&amp;nbsp;beginning&amp;nbsp;of a block use a caret (^).

Here is a block that prints a string.

&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;^{
    NSString *name = &quot;Batman&quot;;
    NSLog(@&quot;My name is %@&quot;, name);
};&lt;/code&gt;&lt;/pre&gt;
We use the caret (^) character to define the beginning of a block literal, and if there are any arguments they are contained in () followed by the block code itself contained in {}.

An example of a block that takes an int as an argument and returns the square value.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;^(int value){
    return value*value;
}&lt;/code&gt;&lt;/pre&gt;
You don&#39;t have to declare the return type of a block, it can be inferred from the code in the block.

Most of the time we pass the block to a method directly, but we can also assign it to a block variable.  The syntax for declaring a block variable is &quot;return_type (^name) (arguments)&quot;  If we declare a block variable &quot;square&quot; and assign to it the block we used in the previous example, it would look like this.

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;int (^square) (int) = ^(int value){
    return value*value;
};
&lt;/code&gt;&lt;/pre&gt;
You can call this block just like a function.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;int square_value = square(5);&lt;/code&gt;&lt;/pre&gt;
We can also create a type definition for a variable that holds a block by using typedef.  The syntax is similar to declaring a block variable name &quot;typedef return_type (^type_name) (arguments)&quot;  Then we can declare the block variables with &quot;type_name block_name = ^(arguments){...}&quot;&lt;br /&gt;
&lt;br /&gt;
Blocks are closures, therefore they have access to local variables when the block is created.  Local variables are read only.  If you want to be able to change the value of local variables, they need to be declared with __block.&lt;br /&gt;
&lt;br /&gt;
To implement multithreading in iOS we use GCD (Grand Central Dispatch).  Any operation that takes a long time to execute might lock the UI (User Interface) while it is being performed.  For example, anything network related, like getting an image from a remote server.  If the image is large enough, it might take a minute or two to download.  If we don&#39;t use a different thread for downloading the image, the whole app will be locked for the duration of the time it takes to download the image.  In cases like this it is a good idea to use GCD to improve the user experience.

This is where blocks become very useful to programmers.&lt;br /&gt;
&lt;br /&gt;
GCD is a C API, therefore it is not object oriented API.  The most basic use of GCD is to create a queue, and then to put blocks on that queue to be executed in a different thread by the system.  The function used to create a queue and put a block on one are as follows

&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;//to create a queue
dispatch_queue_t dispatch_queue_create(const char *label, NULL);

//to put a block on a queue
void dispatch_async(dispatch_queue_t queue, dispatch_block_t block):
&lt;/code&gt;&lt;/pre&gt;
^dispatch_block_t is a prototype of blocks submitted that takes no arguments and doesn&#39;t return anything.

Let&#39;s say we have a method that downloads an xml file from the internet.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;-(void)fetchXML
{
    NSString *URLString = @&quot;example.com/example.xml&quot;;
    NSURL *URL = [NSURL URLWithString:[URLString
                        stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
    NSData *dataXML = [NSData dataWithContentsOfURL:URL];
    NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:dataXML];
    [xmlParser setDelegate:self];
    BOOL success = [xmlParser parse];
    // test the result
    if (success) {
        NSLog(@&quot;No errors&quot;);
    } else {
        NSLog(@&quot;Error&quot;);
    }
}&lt;/code&gt;&lt;/pre&gt;
To execute the fetching of the file on a different thread, we need to do the following modifications to our code.  Create a queue and then put the code as a block on that queue.
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;-(void)fetchXML
{
    dispatch_queue_t fetchQueue = dispatch_queue_create(&quot;fetch xml&quot;, NULL);
    dispatch_async(fetchQueue, ^{
        NSString *URLString = @&quot;example.com/example.xml&quot;;
        NSURL *URL = [NSURL URLWithString:[URLString
                         stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
        NSData *dataXML = [NSData dataWithContentsOfURL:URL];
        NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:dataXML];
        [xmlParser setDelegate:self];
        BOOL success = [xmlParser parse];
        // test the result
        if (success) {
            NSLog(@&quot;No errors&quot;);
        } else {
            NSLog(@&quot;Error&quot;);
        }
   });
}&lt;/code&gt;&lt;/pre&gt;
There is just one more rule about using GCD for multithreading.  When we have code that makes changes to UIKit objects, we need to dispatch that block of code in the main queue.  The way to get the main queue is with &quot;dispatch_get_main_queue&quot;.  
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;dispatch_async(dispatch_get_main_queue(), ^{....});
&lt;/code&gt;&lt;/pre&gt;
This will get you started with GCD.  There are a lot more functions that you can use in GCD, consult the &lt;a href=&quot;https://developer.apple.com/library/ios/#documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html&quot; target=&quot;_blank&quot;&gt;apple docs&lt;/a&gt; for more details on more advanced uses of GCD.&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/222849936984899244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/03/introduction-to-blocks-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/222849936984899244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/222849936984899244'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/03/introduction-to-blocks-and.html' title='Introduction to Blocks and Multithreading in iOS'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-6284666826675745790</id><published>2013-01-28T07:40:00.004-08:00</published><updated>2014-02-02T13:59:51.291-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="iphone"/><category scheme="http://www.blogger.com/atom/ns#" term="NSUserDefaults"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 4.5"/><title type='text'>How to Use NSUserDefaults to Store App Preferences</title><content type='html'>If your app needs to store a small amount of user preferences, using NSUserDefaults is easy and&amp;nbsp;convenient&amp;nbsp;way to do it.&lt;br /&gt;
&lt;br /&gt;
Start a new Single View project in Xcode. &amp;nbsp;I named it NSUserDefaultsTutorial. &amp;nbsp;Open MainStoryboard.storyboard. &amp;nbsp;Go to the object library (lower right corner) and drag a Segmented Control object to the scene. &amp;nbsp;With the segmented control selected go to the attributes inspector (option+command+4) and change the segments value to 3. &amp;nbsp;Double clicking on each segment, change their titles to A, B, C. &amp;nbsp;This is what the project should look like at this point.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhh1-orPQSQuxsg8JY95xqw58CkSp3d89tJiDBvhQVfRb0TT3Ywiyh7N79hz2mxB_R8JvX-A3HEmJL2DWUDzJyzY9McZuCof0bnV9LHFfE0ZCiMHyqP4JOmBtzbTdbveNaGPuBgzQ8o9Zs/s1600/12_segmented_control.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;410&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhh1-orPQSQuxsg8JY95xqw58CkSp3d89tJiDBvhQVfRb0TT3Ywiyh7N79hz2mxB_R8JvX-A3HEmJL2DWUDzJyzY9McZuCof0bnV9LHFfE0ZCiMHyqP4JOmBtzbTdbveNaGPuBgzQ8o9Zs/s640/12_segmented_control.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We need to create an outlet for the segmented control. &amp;nbsp;Click on the assistant editor, press control and drag from the segmented control to ViewController.h When you release the mouse key a pop-up shows up. &amp;nbsp;Name your outlet segmentedControl and leave everything else as is.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHObRQ_6HHEvRSB8t42njxT_HqXiNhuQe0fSsSUZOLMdv6E8XaPyJFmiXpyLI91WZS_mtEUA5PvYySfxyIq4OFg-d-xLrIfyqkmYIoc6qsj3FGvcNzmcWXAXDp_O5gYqCtI5otCes1fok/s1600/12_create_outlet.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;362&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHObRQ_6HHEvRSB8t42njxT_HqXiNhuQe0fSsSUZOLMdv6E8XaPyJFmiXpyLI91WZS_mtEUA5PvYySfxyIq4OFg-d-xLrIfyqkmYIoc6qsj3FGvcNzmcWXAXDp_O5gYqCtI5otCes1fok/s640/12_create_outlet.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Click connect to finish creating the outlet.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0Z-btBJVP6XMJGveMsjiKAAI9LTp4E72pJj0n12MFKGtkS_YBG-jEoBy8SSljUB5sqTk4mzwKHrJpS3AyGPMqKgqis_NUPH9Mizdj1Ffh3y5PVnvATOf5u20nh2_CuC8Q2KY0VcMEk0Y/s1600/12_create_outlet2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;356&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0Z-btBJVP6XMJGveMsjiKAAI9LTp4E72pJj0n12MFKGtkS_YBG-jEoBy8SSljUB5sqTk4mzwKHrJpS3AyGPMqKgqis_NUPH9Mizdj1Ffh3y5PVnvATOf5u20nh2_CuC8Q2KY0VcMEk0Y/s640/12_create_outlet2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We also need to create an action that changes the user defaults every time the value of the segmented control is changed. &amp;nbsp;Again, control+drag from the segmented control but this time to ViewController.m instead of the .h file. &amp;nbsp;Name the action changeValue and leave everything else as is.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJaBJS70GB0CtcCRWhPPkMwFgL5H-vqyn0pXCBM2Y4EdUQMbPzWm21W2VkIqXWPDcX-xC3VUczLCAtDQC7ukmlLY2BuH0QiRxXYtpIvrGzN6y2Bpi5bZvFVaRDgPWC9KyGLupkxQwUQHY/s1600/12_create_action.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;372&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJaBJS70GB0CtcCRWhPPkMwFgL5H-vqyn0pXCBM2Y4EdUQMbPzWm21W2VkIqXWPDcX-xC3VUczLCAtDQC7ukmlLY2BuH0QiRxXYtpIvrGzN6y2Bpi5bZvFVaRDgPWC9KyGLupkxQwUQHY/s640/12_create_action.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Click on connect to finish creating the action. &amp;nbsp;This is the code created automatically by Xcode.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgChySvb0w7mh-vrL5rlkTZ6ErpWZCc9LSATnG5SHNQ6_a7NWm2o5ZmkufYSB6-CBiJ_9kSUM3DtTsI6nbhJXWlHl7gUF71E0-zFVYPvLkJnvtd58-TxdL5LlmHNAJ-wjN2EtcvSh_FX6A/s1600/12_create_action2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgChySvb0w7mh-vrL5rlkTZ6ErpWZCc9LSATnG5SHNQ6_a7NWm2o5ZmkufYSB6-CBiJ_9kSUM3DtTsI6nbhJXWlHl7gUF71E0-zFVYPvLkJnvtd58-TxdL5LlmHNAJ-wjN2EtcvSh_FX6A/s1600/12_create_action2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
When the app starts we have to read what the last value of the segmented control was from NSUserDefaults. &amp;nbsp;We can do this in -viewDidLoad in ViewController.m&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYTtUPOm83qQ1mlV7VqQV54V9red-XdvYUgtRqmhX1mXzlKT-KA01Fd5hQSdlaPRL0AeUeDJ99sUArLKiYN-ukqpKFYoNPXpq0fGgWqCkpsuvjnZ5wU3OdNAsE2PRnSRhWZfHdnnfoJ2A/s1600/12_viewDidLoad.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;104&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYTtUPOm83qQ1mlV7VqQV54V9red-XdvYUgtRqmhX1mXzlKT-KA01Fd5hQSdlaPRL0AeUeDJ99sUArLKiYN-ukqpKFYoNPXpq0fGgWqCkpsuvjnZ5wU3OdNAsE2PRnSRhWZfHdnnfoJ2A/s640/12_viewDidLoad.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Finally, we have to implement -changeValue to store the new value of the segmented control in NSUserDefaults every time the segmented control changes. &amp;nbsp;Just make sure to use the same key as in -viewDidLoad.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKxENLRSUzYkzPjuEFrgnXqhW-N0JXgimcv4049UbMG-nrdb1otxfFYWJFCBv9bttXQ81EJIyVex_Z2ei5zQKqYyLwVho7WE1WSd7yVoVywoiPJE8c76TiDKHgZbENDouphpOjsZVT9Ak/s1600/12_changeValue.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;31&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKxENLRSUzYkzPjuEFrgnXqhW-N0JXgimcv4049UbMG-nrdb1otxfFYWJFCBv9bttXQ81EJIyVex_Z2ei5zQKqYyLwVho7WE1WSd7yVoVywoiPJE8c76TiDKHgZbENDouphpOjsZVT9Ak/s640/12_changeValue.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Run the app (command+r) click on the C segment and then press the home button. &amp;nbsp;Quit the&amp;nbsp;simulator&amp;nbsp;and then launch the app again. &amp;nbsp;This time the segmented control will have the C segment selected instead of the A.&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/6284666826675745790/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/01/how-to-use-nsuserdefaults-to-store-app.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/6284666826675745790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/6284666826675745790'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/01/how-to-use-nsuserdefaults-to-store-app.html' title='How to Use NSUserDefaults to Store App Preferences'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhh1-orPQSQuxsg8JY95xqw58CkSp3d89tJiDBvhQVfRb0TT3Ywiyh7N79hz2mxB_R8JvX-A3HEmJL2DWUDzJyzY9McZuCof0bnV9LHFfE0ZCiMHyqP4JOmBtzbTdbveNaGPuBgzQ8o9Zs/s72-c/12_segmented_control.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-5975984686714720955</id><published>2013-01-26T15:15:00.004-08:00</published><updated>2014-02-02T13:59:37.883-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS 6"/><category scheme="http://www.blogger.com/atom/ns#" term="iphone"/><category scheme="http://www.blogger.com/atom/ns#" term="plist"/><category scheme="http://www.blogger.com/atom/ns#" term="UITableView"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 4.5"/><title type='text'>How to Populate a UITableView From a plist (property list)</title><content type='html'>Start a new &quot;single view&quot; project (I named it PopulateUITableView). &amp;nbsp;Delete ViewController.h and ViewController.m from the project navigator (command+1). &amp;nbsp;Open MainStoryboard.storyboard and delete the scene that came with the template. &amp;nbsp;In the object library find a Table View Controller and drag it as a new scene. &amp;nbsp;This is what the project should look like at this point.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh0vwGTBsEPWkOlj736gQaChLi-vjMQM4R5C1WABrWPagm09psEnhhPehtn0fv9pCVJc0wbLoucA1pOFRZiCHB4ZgF6sIfnfdB7tQNu8IWoWiDSQLHsVpkUNcjhgBqrcUQF-n64sDqvBk/s1600/11_table_view_controller.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;353&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh0vwGTBsEPWkOlj736gQaChLi-vjMQM4R5C1WABrWPagm09psEnhhPehtn0fv9pCVJc0wbLoucA1pOFRZiCHB4ZgF6sIfnfdB7tQNu8IWoWiDSQLHsVpkUNcjhgBqrcUQF-n64sDqvBk/s640/11_table_view_controller.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp;To manage the table view we need to create a new class TableViewController that is a s subclass of UITableViewController. &amp;nbsp;(command+N) create a new Objective-C class name it TableViewController and make sure that it is a subclass of UITableViewController.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpIHcZvXFx2bEyMb6zWLE7bLA7n62LgCJ6QwU5DUURnmwSfDyY1_j3JU-Rrq0GH57wWfZzIZ0SmCyqXNebdlJygVTRmcNSa392qmPrBS2QU_GxresWfRskKV0Lhxzd9174rt9a3SRRKcc/s1600/11_new_tableViewController.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;432&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpIHcZvXFx2bEyMb6zWLE7bLA7n62LgCJ6QwU5DUURnmwSfDyY1_j3JU-Rrq0GH57wWfZzIZ0SmCyqXNebdlJygVTRmcNSa392qmPrBS2QU_GxresWfRskKV0Lhxzd9174rt9a3SRRKcc/s640/11_new_tableViewController.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Go back to MainStoryboard.storyboard. &amp;nbsp;Select the Table View Controller, go to the identity inspector (option+command+3) and change the custom class to TableViewController, the class we just created.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2iYjIA_Hzo3XchJW_EC92U0gBC9oICgORIC_8s4-A-O_SYSlRXjSdydzVvC0kcLdBtNmgACws2tpcK7Kvh8DKvXRe-pgKpwoUPxU6tNhfaTPx3UcAplzsBDt9rTl81l4pfxf9F7GcvwI/s1600/11_custom_class.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;440&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2iYjIA_Hzo3XchJW_EC92U0gBC9oICgORIC_8s4-A-O_SYSlRXjSdydzVvC0kcLdBtNmgACws2tpcK7Kvh8DKvXRe-pgKpwoUPxU6tNhfaTPx3UcAplzsBDt9rTl81l4pfxf9F7GcvwI/s640/11_custom_class.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Click on the Table View Cell and go to Attributes Inspector (option+command+4) and change the style of the cell from basic to subtitle.&lt;br /&gt;
&lt;br /&gt;
It is time to create the plist file. &amp;nbsp;Create a new file (command+N) under iOS pick Resource and then select Property List. &amp;nbsp;Name the file Data. &amp;nbsp;This will create a Data.plist file. &amp;nbsp;Open Data.plist and change the type of the root key to array and add three new items under root by clicking on the plus sign. &amp;nbsp;Change their type to dictionary and for each item add two new sub-items of type string. &amp;nbsp;One string should have the name city and the other state for each item. &amp;nbsp;Give value for each city to New York, Chicago, and Los Angeles and their respective state names. &amp;nbsp;This is what Data.plist should look like after you are done.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrLmUqUJ9ARbUaDcfi6bqA-8cDigQK6XXXsnIJ2dIWAZFslZgDdHz__2R-FWY8gXKt9oMiXa55zieem9Fs73NsP5q-w9P-enhpXBAsU38v5PFQ_tM0SOxwwOdX9i_W35a5HUC23DmsECE/s1600/11_plist_file.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;294&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrLmUqUJ9ARbUaDcfi6bqA-8cDigQK6XXXsnIJ2dIWAZFslZgDdHz__2R-FWY8gXKt9oMiXa55zieem9Fs73NsP5q-w9P-enhpXBAsU38v5PFQ_tM0SOxwwOdX9i_W35a5HUC23DmsECE/s640/11_plist_file.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Next, we need to pull the data from the plist and load it into an array. &amp;nbsp;To do that we declare a NSArray property in TableViewController.h&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYDDZBFwUNN9UZQdys0bvPDJIUxjW8r6L0xJL5UsG6DOSVVykemSNZulm20kjY9cbHE-UYi4qYs6XFt3xertgCR0RU7LGp1Q68G0U8zhplujuJaaKcXVSKar2xMniMIXckX9gaYsFYLKU/s1600/11_tableViewProperty_h.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;132&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYDDZBFwUNN9UZQdys0bvPDJIUxjW8r6L0xJL5UsG6DOSVVykemSNZulm20kjY9cbHE-UYi4qYs6XFt3xertgCR0RU7LGp1Q68G0U8zhplujuJaaKcXVSKar2xMniMIXckX9gaYsFYLKU/s640/11_tableViewProperty_h.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Open TableViewController.m &amp;nbsp; Synthesize the property and write a getter that initializes the array with the content of the plist file.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1cVm9uhQzBxTJkddeNWIDQ4_1KLQ83NbWD6h8LlCEqDKNr3CDway-zL3DrtqvDIDHpxiCJRRZ5WR38ff1SW0JLlUULH5ETn-idMpPR_rnJUepoDQAbLLKF1lfYOL-f_CX7v_QPqTlk_U/s1600/11_syntehsize_property.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;170&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1cVm9uhQzBxTJkddeNWIDQ4_1KLQ83NbWD6h8LlCEqDKNr3CDway-zL3DrtqvDIDHpxiCJRRZ5WR38ff1SW0JLlUULH5ETn-idMpPR_rnJUepoDQAbLLKF1lfYOL-f_CX7v_QPqTlk_U/s640/11_syntehsize_property.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Finally, we have to implement the two required table view data source methods &lt;i&gt;- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section&lt;/i&gt; and &lt;i&gt;- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdsjw7RcspRvd178hVXnnvNeqW3RuO09xbhV-StQgOovni2rpT5ijubTUh5pSkajtpqlDgiW_OkaUphHXyoNk_fuqWma6Pix84xG6nTSAlB-98rUsigqDnhqU7Hn1pIaOehR64D7RcQhM/s1600/11_data_source_methods.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;288&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdsjw7RcspRvd178hVXnnvNeqW3RuO09xbhV-StQgOovni2rpT5ijubTUh5pSkajtpqlDgiW_OkaUphHXyoNk_fuqWma6Pix84xG6nTSAlB-98rUsigqDnhqU7Hn1pIaOehR64D7RcQhM/s640/11_data_source_methods.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
Run the app (command+R) and the table will be loaded from the plist file.&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/5975984686714720955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/01/how-to-populate-uitableview-from-plist.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/5975984686714720955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/5975984686714720955'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/01/how-to-populate-uitableview-from-plist.html' title='How to Populate a UITableView From a plist (property list)'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh0vwGTBsEPWkOlj736gQaChLi-vjMQM4R5C1WABrWPagm09psEnhhPehtn0fv9pCVJc0wbLoucA1pOFRZiCHB4ZgF6sIfnfdB7tQNu8IWoWiDSQLHsVpkUNcjhgBqrcUQF-n64sDqvBk/s72-c/11_table_view_controller.png" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-3731757150563695041</id><published>2013-01-16T08:32:00.000-08:00</published><updated>2014-02-02T13:59:24.762-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Decimal Pad"/><category scheme="http://www.blogger.com/atom/ns#" term="iOS6"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 4"/><title type='text'>How to Dissmis Decimal Pad Keyboard </title><content type='html'>This tutorial will teach you how to dismiss a keyboard (decimal pad, number pad, ....) that doesn&#39;t have a &quot;return&quot; key. &amp;nbsp;There are a few ways that this can be achieved, but the easiest one is by using a&amp;nbsp;UITapGestureRecognizer to &quot;catch&quot; any taps on the screen outside of the keyboard area.&lt;br /&gt;
&lt;br /&gt;
Start a new &quot;Single View Application&quot;project in Xcode using ARC and storyboards. &amp;nbsp;I named my project DismissDecimalPad. &amp;nbsp;Open MainStoryboard.storyboard and drag a UITextField from the object library to the scene. &amp;nbsp;Open the attributes inspector (option+command+4) for the UITextField and change to keyboard value to &#39;Decimal Pad&#39;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq3GWNmQOxEt8j65ASbuK8Gik11JKviyRIo20ZPG6v374fWQtRw3xRV5mddY6ZaeD1b2JNAaCJ2s1b5zxLDAXK8TEEKWbe5h_k9wQWCuA7wVQkWwPUm7UMcOmGz6sXzSZyIHGjn0bqZhs/s1600/10_uitextfield.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;286&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq3GWNmQOxEt8j65ASbuK8Gik11JKviyRIo20ZPG6v374fWQtRw3xRV5mddY6ZaeD1b2JNAaCJ2s1b5zxLDAXK8TEEKWbe5h_k9wQWCuA7wVQkWwPUm7UMcOmGz6sXzSZyIHGjn0bqZhs/s400/10_uitextfield.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Open ViewController.m and in viewDidLoad declare and initialize a UITabGestureRecognizer that calls tap: when a tap is recognized. &amp;nbsp;We also have to attach the gesture recognizer to the view.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXJi4WAsLM8o5ud667JvUmbHoRQfHP0bNowAALZ3dk10UyD3QbPv4ucDj4l_JaRaWfb41gqNHcqiLXv-Uyq1t5ZXDyLZdiTwawQJKaeKcajQUNkwtn3kOQYjeHKkrmBf9KjhC6ekfOico/s1600/10_tapgesturerecognizer.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXJi4WAsLM8o5ud667JvUmbHoRQfHP0bNowAALZ3dk10UyD3QbPv4ucDj4l_JaRaWfb41gqNHcqiLXv-Uyq1t5ZXDyLZdiTwawQJKaeKcajQUNkwtn3kOQYjeHKkrmBf9KjhC6ekfOico/s1600/10_tapgesturerecognizer.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
All that is left to do is implement tap:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0aKyZBZZp35_hDxMSQk90X3z6ixj3v__vdspHqh9DDNmbYdsb588Baw_Z45A7sRSpImZJzuRGwBodNKCNMVff-RZ9ULg3lYNzjGmMnkRH8U_OPZ9REtliG2f3DxemWIUyz_YFcVoe2h0/s1600/10_tap.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0aKyZBZZp35_hDxMSQk90X3z6ixj3v__vdspHqh9DDNmbYdsb588Baw_Z45A7sRSpImZJzuRGwBodNKCNMVff-RZ9ULg3lYNzjGmMnkRH8U_OPZ9REtliG2f3DxemWIUyz_YFcVoe2h0/s1600/10_tap.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Build and run the app. &amp;nbsp;When you are done editing the text field tap anywhere outside of the keyboard area and the keyboard will be dismissed. &amp;nbsp;This can be used for other types of keyboards not only decimal pad.&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/3731757150563695041/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2013/01/how-to-dissmis-decimal-pad-keyboard.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/3731757150563695041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/3731757150563695041'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2013/01/how-to-dissmis-decimal-pad-keyboard.html' title='How to Dissmis Decimal Pad Keyboard '/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgq3GWNmQOxEt8j65ASbuK8Gik11JKviyRIo20ZPG6v374fWQtRw3xRV5mddY6ZaeD1b2JNAaCJ2s1b5zxLDAXK8TEEKWbe5h_k9wQWCuA7wVQkWwPUm7UMcOmGz6sXzSZyIHGjn0bqZhs/s72-c/10_uitextfield.png" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-5283453730492277754</id><published>2012-09-16T18:55:00.001-07:00</published><updated>2014-02-02T13:59:11.421-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS 5"/><category scheme="http://www.blogger.com/atom/ns#" term="ipad"/><category scheme="http://www.blogger.com/atom/ns#" term="iphone"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 4"/><title type='text'>How to Play Audio in iOS</title><content type='html'>In Xcode create a new iOS application using the &quot;Single View Application&quot; template. &amp;nbsp;Name the application AudioPlayer and use ARC and Storyboards. &amp;nbsp;Open MainStoryboard.storyboard and drag a button to the available scene. &amp;nbsp;Change the text of the button to &quot;play audio&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIixBSH538G94VQ-bf9cQz69psi8TCU9Sj-MmX7n6s7-byVlpEgHJFsU-Lp9bgQZh65aluzpQ1AsTPIQPs73Y-lLliSQcBZHp6MspQvnOw3NEFJe1uFtfv3NVkTmFNNRqEZ6ID3GXfYLU/s1600/9_add_button.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIixBSH538G94VQ-bf9cQz69psi8TCU9Sj-MmX7n6s7-byVlpEgHJFsU-Lp9bgQZh65aluzpQ1AsTPIQPs73Y-lLliSQcBZHp6MspQvnOw3NEFJe1uFtfv3NVkTmFNNRqEZ6ID3GXfYLU/s1600/9_add_button.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We need to add and action for this button. &amp;nbsp;Click on the assistant editor and ViewController.h is opened to the side of the storyboard.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha7hWOruRDqQEFaRWteRi4b6BMpeRR_-jHJP41TRIik0-iPpZe9oV3AzCSl-y8zyOd4sKR5t9cqUONSlhQuipsn6Ra34vKiWqNU9pA8-Fr_AQAzdJ7Mum3ixl17LVczhkJwStUBw4xWgs/s1600/9_assistant_edito.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha7hWOruRDqQEFaRWteRi4b6BMpeRR_-jHJP41TRIik0-iPpZe9oV3AzCSl-y8zyOd4sKR5t9cqUONSlhQuipsn6Ra34vKiWqNU9pA8-Fr_AQAzdJ7Mum3ixl17LVczhkJwStUBw4xWgs/s1600/9_assistant_edito.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Press Ctrl and drag from the button to the ViewController.h file and drop below the @interface line. &amp;nbsp;In the pop-up that opens select action for connection and name it playAudio. &amp;nbsp;Everything else can remain as default.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKgFLbkAJrsS6svv9vW1yNMdhNqmtObIYnX6ARyNGB5HPB4w-cQTQ7p2yE8xwjwBRngp2lJAoLApsiEnIFStiVA7ghmgTmXM8J8HiwUNCFOnmGUvvoNewGfPHpDpurRIN6euakZMYE0qY/s1600/9_set_action.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKgFLbkAJrsS6svv9vW1yNMdhNqmtObIYnX6ARyNGB5HPB4w-cQTQ7p2yE8xwjwBRngp2lJAoLApsiEnIFStiVA7ghmgTmXM8J8HiwUNCFOnmGUvvoNewGfPHpDpurRIN6euakZMYE0qY/s1600/9_set_action.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
We are going to use the AVAudioPlayer class to play sound. &amp;nbsp;This class is defined in the AVFoundation framework. &amp;nbsp;Therefore, we need to add this framework to our project. &amp;nbsp;If you don&#39;t know how to do this read &lt;a href=&quot;http://code-and-coffee.blogspot.com/2012/09/how-to-add-frameworks-in-xcode-4.html&quot; target=&quot;_blank&quot;&gt;How to Add Frameworks in Xcode 4&lt;/a&gt;. &amp;nbsp;Next, add #import &amp;lt;AVFoundation/AVFoundation.h&amp;gt; at the top of ViewController.m&lt;br /&gt;
&lt;br /&gt;
Drag and drop the mp3 file that you want to play in your app. &amp;nbsp;Drag the file to the project navigator in Xcode. &lt;br /&gt;
&lt;br /&gt;
Now go back to ViewController.m and finish the playAudio method. &amp;nbsp;We need to declare AVAudioPlayer and load the sound file from an NSURL. &amp;nbsp;Type in the following code. &amp;nbsp;I have named my sound file audio.mp3 so do the necessary changes if you used a different name.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ3Sfpvpxqa-5xlTDyyYTN_-Y41gNnFtfR1N7pp4-GVknEYaCLJ-zcPis-sp8WqUcyusAregvmf7HcXWfIw7SwtOXuEs7r3MDs0Ai3HAkDsvhz-wcLAthTEGbJL4OOghQyum6bwkBRvx8/s1600/9_playAudio_method.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ3Sfpvpxqa-5xlTDyyYTN_-Y41gNnFtfR1N7pp4-GVknEYaCLJ-zcPis-sp8WqUcyusAregvmf7HcXWfIw7SwtOXuEs7r3MDs0Ai3HAkDsvhz-wcLAthTEGbJL4OOghQyum6bwkBRvx8/s1600/9_playAudio_method.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
If you load the app on your device, you can hear the sound file being played after you press the button. Unfortunately, the current iOS simulator that comes with Xcode 4.4 is broken when you try to play sound and it fails.&lt;br /&gt;
&lt;br /&gt;
For more information on iOS programming and Xcode consult&amp;nbsp;&lt;a href=&quot;http://amzn.to/LIupIU&quot; target=&quot;_blank&quot;&gt;iOS Programming: The Big Nerd Ranch Guide (3rd Edition)&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href=&quot;http://amzn.to/MMhkCY&quot; target=&quot;_blank&quot;&gt;The iOS 5 Developer&#39;s Cookbook: Core Concepts and Essential Recipes for iOS Programmers (3rd Edition)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/5283453730492277754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2012/09/how-to-play-audio-in-ios.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/5283453730492277754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/5283453730492277754'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2012/09/how-to-play-audio-in-ios.html' title='How to Play Audio in iOS'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIixBSH538G94VQ-bf9cQz69psi8TCU9Sj-MmX7n6s7-byVlpEgHJFsU-Lp9bgQZh65aluzpQ1AsTPIQPs73Y-lLliSQcBZHp6MspQvnOw3NEFJe1uFtfv3NVkTmFNNRqEZ6ID3GXfYLU/s72-c/9_add_button.png" height="72" width="72"/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-4784151676905435436</id><published>2012-09-14T11:25:00.001-07:00</published><updated>2014-02-02T13:58:54.758-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS 5"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 4"/><title type='text'>How to Add Frameworks in Xcode 4</title><content type='html'>If you need to add a framework in Xcode 4, click on your project in the project navigator, then click on the target. &amp;nbsp;Next, click on the Build Phases tab.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvA7M4YcmXgOYJfriwL5pODjNb7VAtm1hY3_Sgx9mCSFv7adSIVqOy59kwRLFNqjrgu7znUqaALG6k9MErK5p07ggUjjKKu7dem1v0Lg7qCLeAn-3NQ9oxuEycF2hQLIs4eTBfo0uX-lg/s1600/8_add_a_framework.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvA7M4YcmXgOYJfriwL5pODjNb7VAtm1hY3_Sgx9mCSFv7adSIVqOy59kwRLFNqjrgu7znUqaALG6k9MErK5p07ggUjjKKu7dem1v0Lg7qCLeAn-3NQ9oxuEycF2hQLIs4eTBfo0uX-lg/s1600/8_add_a_framework.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Under build phases expend &quot;Link Binary With Libraries&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV9J7aSIPcoHlBGbl2y4fA9Hw3I7WPP9tU_vaPSaSRQo6r-dlin0kIpUo_kLVJ3E4hwtXQZXiklbhNEmQ3oTc8ziW1Kjs2Gu5QOxC2ShaXXKowciJBZFoDQw6o0ZCr_KEWqRGI4I-t1Ms/s1600/8_expend_linkBinaryWithLibraries.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV9J7aSIPcoHlBGbl2y4fA9Hw3I7WPP9tU_vaPSaSRQo6r-dlin0kIpUo_kLVJ3E4hwtXQZXiklbhNEmQ3oTc8ziW1Kjs2Gu5QOxC2ShaXXKowciJBZFoDQw6o0ZCr_KEWqRGI4I-t1Ms/s1600/8_expend_linkBinaryWithLibraries.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Click on the &quot;+&quot; and select the framework that you want to add to your project. &amp;nbsp;I am going to add the CoreLocation framework.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8dyw4npwSUWIMpm1U0fyVDvkyoLUaTpJccmt7648JhEIfHn1Tt6Ui5lciuKmqzzsGxDv3pApQUz3a_A36p-DM0LbegBE8TbB6OKSZhiK9dDzIuYM0r_nSsv3YoKyDO78A3UsOOkeP6fc/s1600/8_add_core_location_framework.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8dyw4npwSUWIMpm1U0fyVDvkyoLUaTpJccmt7648JhEIfHn1Tt6Ui5lciuKmqzzsGxDv3pApQUz3a_A36p-DM0LbegBE8TbB6OKSZhiK9dDzIuYM0r_nSsv3YoKyDO78A3UsOOkeP6fc/s1600/8_add_core_location_framework.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Click the &quot;Add&quot; button to add the framework you selected to your project. &amp;nbsp;If you look in the project navigator, you can see the framework that we just added.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiigjeJASGIGLU4jxFpVp4C0BaORupGdF6-Y7ulloxQPxXSEYFvnEE2eWQiyK-UseMEgDlQOkmUKhKL_0RD1wuUXZDYfvx3mVC2oNjLD40DFSXprccGNVEv7etSx1JancgEgs60-yqQT7o/s1600/8_project_navigator.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiigjeJASGIGLU4jxFpVp4C0BaORupGdF6-Y7ulloxQPxXSEYFvnEE2eWQiyK-UseMEgDlQOkmUKhKL_0RD1wuUXZDYfvx3mVC2oNjLD40DFSXprccGNVEv7etSx1JancgEgs60-yqQT7o/s1600/8_project_navigator.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
For more information on iOS programming and Xcode consult&amp;nbsp;&lt;a href=&quot;http://amzn.to/LIupIU&quot; target=&quot;_blank&quot;&gt;iOS Programming: The Big Nerd Ranch Guide (3rd Edition)&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href=&quot;http://amzn.to/MMhkCY&quot; target=&quot;_blank&quot;&gt;The iOS 5 Developer&#39;s Cookbook: Core Concepts and Essential Recipes for iOS Programmers (3rd Edition)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/4784151676905435436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2012/09/how-to-add-frameworks-in-xcode-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/4784151676905435436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/4784151676905435436'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2012/09/how-to-add-frameworks-in-xcode-4.html' title='How to Add Frameworks in Xcode 4'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvA7M4YcmXgOYJfriwL5pODjNb7VAtm1hY3_Sgx9mCSFv7adSIVqOy59kwRLFNqjrgu7znUqaALG6k9MErK5p07ggUjjKKu7dem1v0Lg7qCLeAn-3NQ9oxuEycF2hQLIs4eTBfo0uX-lg/s72-c/8_add_a_framework.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-4750610116822169793</id><published>2012-07-30T09:50:00.000-07:00</published><updated>2014-02-02T13:58:38.611-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS 5"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><category scheme="http://www.blogger.com/atom/ns#" term="UITableViewCell"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 4.3"/><title type='text'>How to Use Custom UITableViewCell</title><content type='html'>This tutorial will be about creating and using a custom UITableViewCell and it assumes knowledge about working with Table Views in iOS 5. &amp;nbsp;In case you need to brush up on how to use Table Views, chapter &amp;nbsp;9 and 10 of &lt;a href=&quot;http://amzn.to/LIupIU&quot; target=&quot;_blank&quot;&gt;iOS Programming: The Big Nerd Ranch Guide (3rd Edition)&lt;/a&gt;&amp;nbsp; has a good explanation on the topic.&lt;br /&gt;
&lt;br /&gt;
We will create a table view that uses custom cells. &amp;nbsp;Each cell will hold three buttons and we will add an image to each button. &amp;nbsp;The project will end up looking like the following.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw1-fnFChar56oSAaX_AF9ML8umPnSqcKBYPFGgINk8ViX54Z4ppM6o-fNc003CS-P7DjlNGFMjdyyDab6aj_eEMzOX0MD7SjMHXxrlPoV-P9hUzcQwy4yhQC_VksD8ElTHej3Hd_B-2I/s1600/7_finished.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw1-fnFChar56oSAaX_AF9ML8umPnSqcKBYPFGgINk8ViX54Z4ppM6o-fNc003CS-P7DjlNGFMjdyyDab6aj_eEMzOX0MD7SjMHXxrlPoV-P9hUzcQwy4yhQC_VksD8ElTHej3Hd_B-2I/s1600/7_finished.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Open Xcode and start a new project (File-&amp;gt;New Project.) Under iOS select Application and then select Single View Application.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEDych8bAKkqdxKV7H8T0j7GRbDcH-TofwkFTzzXSv5o7hlFXFojtyyR_U9iVQEQKc5V3Bp736QjX_f1dsyV3pTzuhCmgzsASMqWYMVvVG7BKP6mv6IzmECRnkzIJL2uEqPzY0-r0_rpw/s1600/7_new_project.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEDych8bAKkqdxKV7H8T0j7GRbDcH-TofwkFTzzXSv5o7hlFXFojtyyR_U9iVQEQKc5V3Bp736QjX_f1dsyV3pTzuhCmgzsASMqWYMVvVG7BKP6mv6IzmECRnkzIJL2uEqPzY0-r0_rpw/s1600/7_new_project.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the Product name to CustomCellTutorial. &amp;nbsp;Device Family should be iPad, and Use Storyboards and Use ARC should be selected.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtoVW2hmfomxzxcg3nBLkXWs7mpbsDVqgOU1sClQGPo4WyvYbgLBeDtG-3SPEuArC-PNB5h7dik5VW9aLqqJrgAxXoOAZrfB2gkuXz9bNlCfiiVaMDChw7u8kWtqmdMkbNc_1R1d4QuhM/s1600/7_save_project.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtoVW2hmfomxzxcg3nBLkXWs7mpbsDVqgOU1sClQGPo4WyvYbgLBeDtG-3SPEuArC-PNB5h7dik5VW9aLqqJrgAxXoOAZrfB2gkuXz9bNlCfiiVaMDChw7u8kWtqmdMkbNc_1R1d4QuhM/s1600/7_save_project.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Open MainStoryboard.storyboard and delete the view controller that was put there by the Xcode template that we used. &amp;nbsp;We are going to use a Table View Controller instead. &amp;nbsp;Open the object library, find a Table View Controller and drag it to the storyboard canvas. &amp;nbsp;If there is no arrow pointing to the new scene that we just added, click on the Table View Controller and then open the Attributes Inspector and under View Controller make sure that Is Initial View Controller check box is selected.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXbqp_8or7A70x_ZaU-f1l0iwBCOJ1tHTlfDJMmWvJ8jI7xavgFWkWpxEKV1wXrKRoWuanBRM-TnHUnfWYpx_JraOWm6f74VNGujJbEzwhuCyCxSLJp0OXHOlOjzY_xEsa1ieC14qPe00/s1600/7_add_tableviewcontroller.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXbqp_8or7A70x_ZaU-f1l0iwBCOJ1tHTlfDJMmWvJ8jI7xavgFWkWpxEKV1wXrKRoWuanBRM-TnHUnfWYpx_JraOWm6f74VNGujJbEzwhuCyCxSLJp0OXHOlOjzY_xEsa1ieC14qPe00/s1600/7_add_tableviewcontroller.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Delete ViewController.h and ViewController.m from the project navigator. &amp;nbsp;We need to add new table view controller that will be used by the UITableViewController instance we added to the storyboard. &amp;nbsp;Create a new file (File-&amp;gt;New-&amp;gt;File.) &amp;nbsp;Under iOS and Cocoa Touch select Objective-C class.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuGGU_Z1mjj5yeFF_U1k2lpCNv2eEwyyAW9xyQtI27nXn1a3bazVsSYFpDB1mPqZKQ8-sfEQ3F06XyiE9718jxxmDi_AITAptb7b43KeBpGAyQc6F9B3uRdVJYvCbhiU_CwqhUvPvKgcg/s1600/7_new_class.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuGGU_Z1mjj5yeFF_U1k2lpCNv2eEwyyAW9xyQtI27nXn1a3bazVsSYFpDB1mPqZKQ8-sfEQ3F06XyiE9718jxxmDi_AITAptb7b43KeBpGAyQc6F9B3uRdVJYvCbhiU_CwqhUvPvKgcg/s1600/7_new_class.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Name the class TableViewController and make it a subclass of UITableViewController. &amp;nbsp;Select the checkbox Targeted for iPad.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRxsxRsSsJlcpX0Xur5tujDmDveK9MXgw-m_xhzVfb8bS_el6nZQPKWJwi8TCQqrsdrrweVpy928gpUAj_74x2hO_oX9Wjw3a8HLtcX_2b4N4HDoTbXtRUYs93TRREvuN2HBkfP_ZNvSE/s1600/7_save_new_class.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRxsxRsSsJlcpX0Xur5tujDmDveK9MXgw-m_xhzVfb8bS_el6nZQPKWJwi8TCQqrsdrrweVpy928gpUAj_74x2hO_oX9Wjw3a8HLtcX_2b4N4HDoTbXtRUYs93TRREvuN2HBkfP_ZNvSE/s1600/7_save_new_class.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we need to tell the UITableViewController instance in MainStoryboard.storyboard to use the new class that we just created. &amp;nbsp;Open MainStoryboard.storyboard. &amp;nbsp;Click on the Table View Controller in the outline view and go to the Identity Inspector. &amp;nbsp;Under Custom Class change the Class name to TableViewController.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrUsc0fBrFXs0ayExHbL-BerUH3cRfvnqOyx9sADpcS96Rx2urs04WnxzaNaEe1vjnazIg86fnx0DC7cfo4vxr7dwEBV1ESEVS8ii2Ryn-clyqVO_eU-Gwynn638FvJq8aD-4udeM-5X8/s1600/7_configure_tableviewcontroller.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrUsc0fBrFXs0ayExHbL-BerUH3cRfvnqOyx9sADpcS96Rx2urs04WnxzaNaEe1vjnazIg86fnx0DC7cfo4vxr7dwEBV1ESEVS8ii2Ryn-clyqVO_eU-Gwynn638FvJq8aD-4udeM-5X8/s1600/7_configure_tableviewcontroller.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
TableViewController is already configure to be the delegate and the datasource for the TableView. &amp;nbsp;We just need to implement the methods that are required by the UITableViewDataSource protocol. &amp;nbsp;Before we do that, we need to create the custom cell class that we are going to be using. &amp;nbsp;Create a new file (File-&amp;gt;New-&amp;gt;File) &amp;nbsp;Under iOS and Cocoa Touch select Objective-C class.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSfdHGbFQrgg0GsaVi3xFtPKZuJO3JAAymGqMw1ovViLdI_oot4PJ7MPv4n9X5vysu3ptlLwXeqD3cfApybfcu9O7Uef0YniS2SGDX3jLXZUyMJ-fCJYta-hMRe_TFvAXGQRTcOQ3C_9E/s1600/7_create_new_customecell_class.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSfdHGbFQrgg0GsaVi3xFtPKZuJO3JAAymGqMw1ovViLdI_oot4PJ7MPv4n9X5vysu3ptlLwXeqD3cfApybfcu9O7Uef0YniS2SGDX3jLXZUyMJ-fCJYta-hMRe_TFvAXGQRTcOQ3C_9E/s1600/7_create_new_customecell_class.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Name the class CustomCell and make it a subclass of UITableViewCell.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJvtzKzNBOjX7ltdfUCmI4dcjivA278EcDOAsdfvrnsxIb0GQwasKRVcBf-m3OrCmiDK-g0qxGpee7ukCxaX_KUU75dLOdCU8S87M-aU8AuCSdnWtzJX_h8fHSJdSWN2Kht6xtUUXaSew/s1600/7_save_customecell.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJvtzKzNBOjX7ltdfUCmI4dcjivA278EcDOAsdfvrnsxIb0GQwasKRVcBf-m3OrCmiDK-g0qxGpee7ukCxaX_KUU75dLOdCU8S87M-aU8AuCSdnWtzJX_h8fHSJdSWN2Kht6xtUUXaSew/s1600/7_save_customecell.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Each custom cell is going to have three buttons inside of it. &amp;nbsp;Open CustomCell.h and create three UIButton properties.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWliFaWK6CDdr9HyjicE6QEM0XJq7WT5c8Dc0TfKjpX-7HdW_6SFPHtoSsw4MEZuDIQVTxcscA-6UbFHPVQkY7rtWBtElGN-HDoyYs2uq0YBQzeskD6vzxyyhFCC17gcBRc_7LgIV46aY/s1600/7_add_cell_properties.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWliFaWK6CDdr9HyjicE6QEM0XJq7WT5c8Dc0TfKjpX-7HdW_6SFPHtoSsw4MEZuDIQVTxcscA-6UbFHPVQkY7rtWBtElGN-HDoyYs2uq0YBQzeskD6vzxyyhFCC17gcBRc_7LgIV46aY/s1600/7_add_cell_properties.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
We need to synthesize the properties, as well. &amp;nbsp;Open CustomCell.m and delete everything that is between @implementation and @end we are not going to need these methods. &amp;nbsp;Synthesize the properties below the @implementation line.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwPYTDhajFAxMxlDh394H56qCCspiCEWDV4b-TpOwZOap-VvI0T7geA17vEPwaNDDgKIMKgpa5sCMUB-i-B8sV2tmNyif7nG0_mdNh6-sOwc-Ou_0T586spVANGho_wQB-G84E8tXsfbs/s1600/7_synthesize_properties.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwPYTDhajFAxMxlDh394H56qCCspiCEWDV4b-TpOwZOap-VvI0T7geA17vEPwaNDDgKIMKgpa5sCMUB-i-B8sV2tmNyif7nG0_mdNh6-sOwc-Ou_0T586spVANGho_wQB-G84E8tXsfbs/s1600/7_synthesize_properties.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
An easy way to initialize the buttons is in the getter. &amp;nbsp;Still in CustomCell.m write getters for all properties that return the button if it&#39;s initialized or initialize if it is not.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3oFjg-XNQU7-A87xGfqt-baL-s1X91vTiZY2QwwNrkWxi1HvGyiqHfJTbdmkXOig7uyZNObO5OmLszS95nOa1cwHUuDOYMi_YtY5sW16xhXab3LYZIJNWohePMouVJ8rg7MQskGKGhLM/s1600/7_initialize_properties.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3oFjg-XNQU7-A87xGfqt-baL-s1X91vTiZY2QwwNrkWxi1HvGyiqHfJTbdmkXOig7uyZNObO5OmLszS95nOa1cwHUuDOYMi_YtY5sW16xhXab3LYZIJNWohePMouVJ8rg7MQskGKGhLM/s1600/7_initialize_properties.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
There is one more thing to do before we can use the CustomCell. &amp;nbsp;We need to add the buttons as subviews and to position them properly. &amp;nbsp;There is a UITableViewCell property called contentView that is the superview for content displayed by the cell. &amp;nbsp;We need to add the buttons as subviews to the contentView. &amp;nbsp;To do this, we need to implement -(void)layoutSubviews in CustomCell.m &amp;nbsp;Type in the following. &amp;nbsp;The comments should explain what each line does.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisF9-Pe4k9-J7Z76GeIAg2pIUPMySuzR1qr7xfJig_J2xAIWbJzf3C90hXAbLBPiY813F4KKmbF4ODxyFvAECi3TvAVdAwfehjQR5PYaem9V5d3LgFHznrTccdUP2FGV3fIRH1KIhZaDQ/s1600/7_layoutSubviews.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisF9-Pe4k9-J7Z76GeIAg2pIUPMySuzR1qr7xfJig_J2xAIWbJzf3C90hXAbLBPiY813F4KKmbF4ODxyFvAECi3TvAVdAwfehjQR5PYaem9V5d3LgFHznrTccdUP2FGV3fIRH1KIhZaDQ/s1600/7_layoutSubviews.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
I have downloaded eight images from &lt;a href=&quot;http://commons.wikimedia.org/&quot;&gt;commons.wikimedia.org&lt;/a&gt;&amp;nbsp;that I am going to use in this project. &amp;nbsp;You can use your own images and you can use as many as you want. &amp;nbsp;To add the images to our project, just drag them to the project navigator in Xcode. &amp;nbsp;Select copy items into destination group&#39;s folder before you press finish. &amp;nbsp;This will make a copy of the images and your project will work even if you delete the original images. &amp;nbsp;I have named my images 1 through 8.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ImYQ2414ccMlr0LKgcWs_840aRp2KpfnpBlxT4ii8LXeo2owf4UEcUCGeWMIIAYLlPv-mUk1dbNiCoNjhRZsh1yX5S35Fr2uziZTAePnVgw5XVmy-PwgHbgaORikd6hEnlFBjtht5Vg/s1600/7_copy_files.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ImYQ2414ccMlr0LKgcWs_840aRp2KpfnpBlxT4ii8LXeo2owf4UEcUCGeWMIIAYLlPv-mUk1dbNiCoNjhRZsh1yX5S35Fr2uziZTAePnVgw5XVmy-PwgHbgaORikd6hEnlFBjtht5Vg/s1600/7_copy_files.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
We will use an array as our model to display our images, since this is a very simple model we can add it directly to our controller. &amp;nbsp;In TableViewController.h add an array property.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibDHqvbUijrCiL2HqMHd7x9xDFjKf6wZiO9gjseQ0rq4gvD6IBp7yRqOwBIklW1PlQWE32DUHjxabXMaxOtkKifK8ShZEScacXWaEaZuDmhFWmm4MURNU97_Tz8bfjC1ztrhqgw3FeUiI/s1600/7_images_property.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibDHqvbUijrCiL2HqMHd7x9xDFjKf6wZiO9gjseQ0rq4gvD6IBp7yRqOwBIklW1PlQWE32DUHjxabXMaxOtkKifK8ShZEScacXWaEaZuDmhFWmm4MURNU97_Tz8bfjC1ztrhqgw3FeUiI/s1600/7_images_property.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In TableViewController.m synthesize images and write a getter for the property that also initializes it.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWf_shg-dgJUdApNV7YhtDR2BLcK3WxtpcFUDQesz4ke-N581NYdoajCeaNRx_9LDW2ANVei8AAdPvmejMWgdli3Bq-n7R_n8rUxkI7LwuLPauwnZC2KyofwM-s9zmwi0imk4SMZ4EY6Y/s1600/7_synthesize_images.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWf_shg-dgJUdApNV7YhtDR2BLcK3WxtpcFUDQesz4ke-N581NYdoajCeaNRx_9LDW2ANVei8AAdPvmejMWgdli3Bq-n7R_n8rUxkI7LwuLPauwnZC2KyofwM-s9zmwi0imk4SMZ4EY6Y/s1600/7_synthesize_images.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The table will have only one section, so either change the method &lt;i&gt;-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView&lt;/i&gt; to return 1 or delete it completely since 1 is the default value.&lt;br /&gt;
&lt;br /&gt;
We need to implement &lt;i&gt;-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section&lt;/i&gt;&amp;nbsp;which returns the number of rows in the table. &amp;nbsp;Since there will be three buttons per row, we divide the size of the array by 3 and return the value. &amp;nbsp;If there is a remainder left we add one to the value in cases when the last row has less than three images.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOLtS4aaXkFYwkScwmLHZfDb13e5DUL0U5Su5QHV61jrPjLzBxsRpCkQ8hyphenhyphen5G03l3kT_CrncOcRGaHNUvmnV39symOkyH5tEvlqNpZlpr89dBzCd-7whZ7yNy4mff-3Lo8R605BuyNaY0/s1600/7_numberOfRowsInSection.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOLtS4aaXkFYwkScwmLHZfDb13e5DUL0U5Su5QHV61jrPjLzBxsRpCkQ8hyphenhyphen5G03l3kT_CrncOcRGaHNUvmnV39symOkyH5tEvlqNpZlpr89dBzCd-7whZ7yNy4mff-3Lo8R605BuyNaY0/s1600/7_numberOfRowsInSection.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Finally, we need to implement &lt;i&gt;-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath&lt;/i&gt;&amp;nbsp; to use our new custom cell we created. &amp;nbsp;First, add &lt;i&gt;#import &quot;CustomCell.h&quot;&lt;/i&gt; at the top of TableViewController.m &amp;nbsp;Copy the method shown below to TableViewController.m&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZOFawMF4PanqF8f6sf8RTFH5Grj7tX9chQCoFM8ogCtP8f7qR1p3iqaoALvyucgl0Ux2sSW3p3H_HRDZ_Zb0IFa7AOvT93ajgS334dWlVmOZBpXB_ZTkp9rloRjGqQ-GMVWDybKZaiDs/s1600/7_cellForRowAtIndexPath.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZOFawMF4PanqF8f6sf8RTFH5Grj7tX9chQCoFM8ogCtP8f7qR1p3iqaoALvyucgl0Ux2sSW3p3H_HRDZ_Zb0IFa7AOvT93ajgS334dWlVmOZBpXB_ZTkp9rloRjGqQ-GMVWDybKZaiDs/s1600/7_cellForRowAtIndexPath.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In&amp;nbsp;MainStoryboard.storyboard, click on the Table View Cell and then in the identity inspector change the class name to CustomCell.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDh_SFQDMftzT5_s_0R3elFKUYQmUxkBUzDNclLNNRxYMmAXz59zCJPKEp1vDveqrio_GD1BQs227mKqfwitxgfQRb_PeaFObWHXBEPFlvxu3MIzs0jpO7aU-1r6a1QcnVjblkSw5PnH4/s1600/7_customCell.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDh_SFQDMftzT5_s_0R3elFKUYQmUxkBUzDNclLNNRxYMmAXz59zCJPKEp1vDveqrio_GD1BQs227mKqfwitxgfQRb_PeaFObWHXBEPFlvxu3MIzs0jpO7aU-1r6a1QcnVjblkSw5PnH4/s1600/7_customCell.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
We need to set the cell identifier for the custom cell. &amp;nbsp;It should be the same as the CellIdentifier we used in the last method we wrote. &amp;nbsp;In our case &quot;Cell.&quot; &amp;nbsp;Click on the Custom Cell in&amp;nbsp;MainStoryboard.storyboard again and open the attributes inspector. &amp;nbsp;Change the identifier to &quot;Cell&quot;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJnqY-4hPilytd9i6laXnko-iVWXiJ5d9qkBgY8eNvB8jX5CR4XDehZ7ap3m-5L5y5zetI2zylOcM418Xm-XE67u3009JOCmfuKcz47ch-UYh_3xsTtCnzpdBnwMM4Of5G_mjwdssksFE/s1600/7_cell_identifier.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJnqY-4hPilytd9i6laXnko-iVWXiJ5d9qkBgY8eNvB8jX5CR4XDehZ7ap3m-5L5y5zetI2zylOcM418Xm-XE67u3009JOCmfuKcz47ch-UYh_3xsTtCnzpdBnwMM4Of5G_mjwdssksFE/s1600/7_cell_identifier.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Finally, need to set the row height for the table view. &amp;nbsp;Open MainStoryboard.storyboard, click on the Table View and then in the size inspector set the Row Height to 200.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAbU8x0PEGWOKWxP-C5t1GmzizDlET0wpns4boxpylTg4hxjYTkTeZ_kQOTIkFRSZLWJcounekIdHcCEdyu2j8zGF44D3Xp0fjs-7fu1393jLLids9Cahg7VrN3cyYLI58GtDJPvwA1Sg/s1600/7_row_height.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAbU8x0PEGWOKWxP-C5t1GmzizDlET0wpns4boxpylTg4hxjYTkTeZ_kQOTIkFRSZLWJcounekIdHcCEdyu2j8zGF44D3Xp0fjs-7fu1393jLLids9Cahg7VrN3cyYLI58GtDJPvwA1Sg/s1600/7_row_height.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Build and run the app. &amp;nbsp;You should see the following if there are no errors.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBabBOePMd6F3xfNq-TRgBw7SwKdzUeT2RekWMc_M4Dw5DXRG0Hrxa-CcPViUv7FT9wJvh0ejKrzbA52Ktx03BLdkiWQy0eqT9ojBontkuRa9wDL7eoOX_cGV9frTNrVCf7_Owj1InRw/s1600/7_finished2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQBabBOePMd6F3xfNq-TRgBw7SwKdzUeT2RekWMc_M4Dw5DXRG0Hrxa-CcPViUv7FT9wJvh0ejKrzbA52Ktx03BLdkiWQy0eqT9ojBontkuRa9wDL7eoOX_cGV9frTNrVCf7_Owj1InRw/s1600/7_finished2.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Download the source code for this project from &lt;a href=&quot;https://github.com/code-and-coffee/CustomCellTutorial.git&quot; target=&quot;_blank&quot;&gt;github&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/4750610116822169793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2012/07/how-to-use-custom-uitableviewcell.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/4750610116822169793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/4750610116822169793'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2012/07/how-to-use-custom-uitableviewcell.html' title='How to Use Custom UITableViewCell'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw1-fnFChar56oSAaX_AF9ML8umPnSqcKBYPFGgINk8ViX54Z4ppM6o-fNc003CS-P7DjlNGFMjdyyDab6aj_eEMzOX0MD7SjMHXxrlPoV-P9hUzcQwy4yhQC_VksD8ElTHej3Hd_B-2I/s72-c/7_finished.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-8084366907572710001</id><published>2012-07-18T13:34:00.000-07:00</published><updated>2014-02-02T14:04:59.692-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS 5"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 4.3"/><title type='text'>Introduction to Storyboards and Segues in iOS 5</title><content type='html'>Storyboard is a new feature introduced in iOS 5 and Xcode 4 that replaces Interface Builder. &amp;nbsp;All view controllers are represented in one storyboard and they are called &quot;Scenes.&quot; &amp;nbsp;Segues are used to transition from one scene (view controller/xib file) to another.&lt;br /&gt;
&lt;br /&gt;
Open Xcode and create a new project. &amp;nbsp;Under iOS select Application and then make it a Single View Application.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhscz-ot_-p7ciSVd7EDyavJ47b3GU3MhVCsFvutMxobgSzhilKsQ6nXSDhLIOwIQ01ObUlCx50ogje0HAL7G2MetMJ6gCR3biWQbZ2tXhHiNx8LlI7BH0OMMaRjUELD7p3t2Fm1KCafC0/s1600/6_create_new_project.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhscz-ot_-p7ciSVd7EDyavJ47b3GU3MhVCsFvutMxobgSzhilKsQ6nXSDhLIOwIQ01ObUlCx50ogje0HAL7G2MetMJ6gCR3biWQbZ2tXhHiNx8LlI7BH0OMMaRjUELD7p3t2Fm1KCafC0/s1600/6_create_new_project.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Use SegueTutorial for Product Name. &amp;nbsp;Make sure that &quot;Use Storyboards&quot; and &quot;Use Automatic Reference Counting&quot; are selected.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTyPSi6ZDhfoKlyRqXJxBgePYb_wWyoQ29t4fr7TztKJsn_pZZfmFEL19sr6XBJuzgCQNIbWSSHu-vwQst0dacsmCJjuAGVgskkk4dTbReKU_JBNDio27JrTlVkrelMNMtzYcKSPOvmGE/s1600/6_save_project.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTyPSi6ZDhfoKlyRqXJxBgePYb_wWyoQ29t4fr7TztKJsn_pZZfmFEL19sr6XBJuzgCQNIbWSSHu-vwQst0dacsmCJjuAGVgskkk4dTbReKU_JBNDio27JrTlVkrelMNMtzYcKSPOvmGE/s1600/6_save_project.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Open MainStoryboard.storyboard from the Project Navigator. &amp;nbsp;We need to add a new scene to the storyboard. &amp;nbsp;From the Object Library find and drag a new View Controller to the storyboard.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilmhp3UGfNh_4wsiES1fq3WQ0LO0ijo2vWQzGXYP1m6cN-Xon66humT9ErsJydpM9efzngLGqQBZ1dWTrBeCK5cr3Tj8M1KcYD0NAofyeF_FE0zUYJ0T2vHBdoSefxw9cPDeR6tgONuKg/s1600/6_add_new_view_controller.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilmhp3UGfNh_4wsiES1fq3WQ0LO0ijo2vWQzGXYP1m6cN-Xon66humT9ErsJydpM9efzngLGqQBZ1dWTrBeCK5cr3Tj8M1KcYD0NAofyeF_FE0zUYJ0T2vHBdoSefxw9cPDeR6tgONuKg/s1600/6_add_new_view_controller.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Find and drag a label from the Object Library to the scene we just added. &amp;nbsp;Change the text of the label to &quot;Second Scene.&quot; &amp;nbsp; We also need to add a button in our original scene. &amp;nbsp;Drag a Round Rect Button to the original scene that was created by Xcode when we first created the project. &amp;nbsp;Double click on the button to change to title to &quot;Transition to Second Scene.&quot; &amp;nbsp;The storyboard should like the following when done with these changes.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwH7NkMugqmEpTb8YmQAQErz9P1cCG0XrqUsb5FCitMbgp-krcnEs7sYSvqejkIyzaSyMWCfbAtUyGsFEWecIUczjAaTju4Hzn0tvl4T4eh4muD8SYDBtr957D6yP1gbsgiN-0nI6v7bM/s1600/6_add_button_and_label.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwH7NkMugqmEpTb8YmQAQErz9P1cCG0XrqUsb5FCitMbgp-krcnEs7sYSvqejkIyzaSyMWCfbAtUyGsFEWecIUczjAaTju4Hzn0tvl4T4eh4muD8SYDBtr957D6yP1gbsgiN-0nI6v7bM/s1600/6_add_button_and_label.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Next we need to create the segue. &amp;nbsp;Press ctrl and drag from the button we just created to the second scene. &amp;nbsp;When you release the mouse button a pop-up menu appears that let&#39;s you choose the type of segue that you want. &amp;nbsp;For this exercise select Modal segue. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6XlrOrNIedcbus3Ap_ZKTLdkS3N2xw4CIJRJbvY7qf_VYagDhDJd6rBs4qVQHrkGG6-Pnae4tq9ZSqSXy2f98KW-V33sCR3gf3Pq1dJFKKIxc2C8uoqu0znZmv1mHHePuQpA60f4lw54/s1600/6_segue_types.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6XlrOrNIedcbus3Ap_ZKTLdkS3N2xw4CIJRJbvY7qf_VYagDhDJd6rBs4qVQHrkGG6-Pnae4tq9ZSqSXy2f98KW-V33sCR3gf3Pq1dJFKKIxc2C8uoqu0znZmv1mHHePuQpA60f4lw54/s1600/6_segue_types.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This is what the storyboard should look like when done.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisHc-cDe0cG2c530sFdEQhxI23k0U0-G-DnRHxnhQYn1j4clzvL0hvwxOwWBMrWDoDU1QlK8murbAsPCLMXI2oRNYd0r7XhPnMNRp4h0HO6trGXxc9eoa8bcxtJWTZV97qd7caQKPSeo0/s1600/6_segue_connected.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisHc-cDe0cG2c530sFdEQhxI23k0U0-G-DnRHxnhQYn1j4clzvL0hvwxOwWBMrWDoDU1QlK8murbAsPCLMXI2oRNYd0r7XhPnMNRp4h0HO6trGXxc9eoa8bcxtJWTZV97qd7caQKPSeo0/s1600/6_segue_connected.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Save and Run the project. &amp;nbsp;Press the &quot;Transition to Second Scene&quot; button and the app goes to the second scene.&lt;br /&gt;
&lt;br /&gt;
If we want to send some data through a segue we need to implant the method &quot;-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender&quot; for more information how to do this, read through the Apple documentation or&amp;nbsp;&lt;a href=&quot;http://amzn.to/MMhkCY&quot; target=&quot;_blank&quot;&gt;The iOS 5 Developer&#39;s Cookbook: Core Concepts and Essential Recipes for iOS Programmers (3rd Edition)&lt;/a&gt;&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/8084366907572710001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2012/07/introduction-to-storyboards-and-segues.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8084366907572710001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/8084366907572710001'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2012/07/introduction-to-storyboards-and-segues.html' title='Introduction to Storyboards and Segues in iOS 5'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhscz-ot_-p7ciSVd7EDyavJ47b3GU3MhVCsFvutMxobgSzhilKsQ6nXSDhLIOwIQ01ObUlCx50ogje0HAL7G2MetMJ6gCR3biWQbZ2tXhHiNx8LlI7BH0OMMaRjUELD7p3t2Fm1KCafC0/s72-c/6_create_new_project.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3770203940285232860.post-1742471167723872031</id><published>2012-07-08T16:34:00.000-07:00</published><updated>2014-02-02T14:03:38.055-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS 5"/><category scheme="http://www.blogger.com/atom/ns#" term="Objective-C"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode 4.3"/><title type='text'>Getting Started with MapKit and iOS</title><content type='html'>&lt;br /&gt;
This is going to be a simple tutorial on using MapKit in iOS 5 with storyboard and ARC.&lt;br /&gt;
&lt;br /&gt;
Open Xcode and start a new project (File-&amp;gt;New-&amp;gt;Project) &amp;nbsp;Under iOS select Application and then Single View Application.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ISabaOyb4HbqZr1_QaqdwOPP7BgTOjkTAMtFACkTmvNqQWnVkLP2kuYg8I9Wx99HK884VAAEvOzMLIrk3bnlLjukTaTaI2tEbFoo17NzKd0OFCKSpFBONUi9ZBggsx1nHrdok5ozOts/s1600/5_new_project.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ISabaOyb4HbqZr1_QaqdwOPP7BgTOjkTAMtFACkTmvNqQWnVkLP2kuYg8I9Wx99HK884VAAEvOzMLIrk3bnlLjukTaTaI2tEbFoo17NzKd0OFCKSpFBONUi9ZBggsx1nHrdok5ozOts/s1600/5_new_project.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Click Next and then set Product Name to FindMe, put anything for Company Identifier. &amp;nbsp;Make sure the Device Family is set to iPhone and that both Use Storyboards and Use ARC are selected.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9py4jViG9hysf-EHBfSpWg_iBP4jdwyu6rC0XLUAdBaXjsmCVGlbHVT-lVJLQPbPoIimh_Pgn18Ae0OooBZLQ5TiczZ2ROzCKWV8IYjG-AV0OK9fCIwgS1KWjJHQa-DVQ2bsYNwhNdo/s1600/5_save_project.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9py4jViG9hysf-EHBfSpWg_iBP4jdwyu6rC0XLUAdBaXjsmCVGlbHVT-lVJLQPbPoIimh_Pgn18Ae0OooBZLQ5TiczZ2ROzCKWV8IYjG-AV0OK9fCIwgS1KWjJHQa-DVQ2bsYNwhNdo/s1600/5_save_project.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Click Next and save the project.&lt;br /&gt;
&lt;br /&gt;
First, we need to add the MapKit framework to our project. &amp;nbsp;Select the FindMe project, then select the FindMe target and then Build Phases tab. &amp;nbsp;Click on the Link Binary With Libraries to see what frameworks are added to the current project.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoC_W7o52JI46ngNLQ38nX5WVBnaCO9EYwk7jX_gYzOtnDrWSuBu3a7T-oJzFRAhfx-OaKVYCB77XJGm68De_R7G3N0rrAQZdDOR2oEtYk6xqZg8vtbsPuso-P8FZ9rf3VFYbOGl-j_50/s1600/5_show_frameworks.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoC_W7o52JI46ngNLQ38nX5WVBnaCO9EYwk7jX_gYzOtnDrWSuBu3a7T-oJzFRAhfx-OaKVYCB77XJGm68De_R7G3N0rrAQZdDOR2oEtYk6xqZg8vtbsPuso-P8FZ9rf3VFYbOGl-j_50/s1600/5_show_frameworks.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
To add a new framework, click on the + button under the Link Binary With Libraries section. &amp;nbsp;A new sheet appears. &amp;nbsp;Find the MapKit.framework and add it to the project.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKiSqAsnsTAEN9ZhcPHCqdWRzmjrFES28HCDIAiXXgOcyp6SSawyjZNpR6v8mX2U5kOj1RsMAWWpZn1Q-5Eb23ssrZQ768PGZSmiD7ChaITZmvzVFywNaekPA97gUvVkcnzMs_vb6_z9I/s1600/5_add_framework.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKiSqAsnsTAEN9ZhcPHCqdWRzmjrFES28HCDIAiXXgOcyp6SSawyjZNpR6v8mX2U5kOj1RsMAWWpZn1Q-5Eb23ssrZQ768PGZSmiD7ChaITZmvzVFywNaekPA97gUvVkcnzMs_vb6_z9I/s1600/5_add_framework.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Next, we need to add a MapView to the storyboard. &amp;nbsp;Open MainStoryboard.storyboard, and drag a Map View from the object library to the storyboard.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaXxIW4BRTelRynRAwR46XfCfh2s1AF45qgyekjSYCsMjPT2MuaI9mVQ8iFpkL4HInb5DpZ0pOKrC6ol7iBGsEoyb3E9VmJsbx7fgyEpgg8Cuyh88k-bHLcyEDtl5FTOAp_bVFAp7KuOA/s1600/5_add_mapview.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaXxIW4BRTelRynRAwR46XfCfh2s1AF45qgyekjSYCsMjPT2MuaI9mVQ8iFpkL4HInb5DpZ0pOKrC6ol7iBGsEoyb3E9VmJsbx7fgyEpgg8Cuyh88k-bHLcyEDtl5FTOAp_bVFAp7KuOA/s1600/5_add_mapview.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
We need to add a property outlet that connects to the MapView. &amp;nbsp;We also need to import the MapKit framework. &amp;nbsp;Open, ViewController.h and do the following changes.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihBhUxomApzYyZfmK9hot4ueFxyVuR9lU9tJ6PCT8AHWMyF8Ob6_A0pnA4b_tnvwZhrXeEq_hcxZTUDCXa51uUUUVK1FusUCoVvLIWkmNKUhUzRenAhwNNjZxKJJqS1jwdPnGsFn41SQM/s1600/5_add_mapview_outlet.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihBhUxomApzYyZfmK9hot4ueFxyVuR9lU9tJ6PCT8AHWMyF8Ob6_A0pnA4b_tnvwZhrXeEq_hcxZTUDCXa51uUUUVK1FusUCoVvLIWkmNKUhUzRenAhwNNjZxKJJqS1jwdPnGsFn41SQM/s1600/5_add_mapview_outlet.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Open, ViewController.m and synthesize the mapView property.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQpdSvbWjOGDuDQBa7w5vWffO8HHGVs4_dZAKWVIM4SgGAv_dHzp-6nEaMEHSJm9hEyi_VR29tcLd4bWKn_TtwgNvXDUHTlC1iMTzhII22qa5ARQwyYxfWQrWbmJnxrDwN-s0ECyt5OP8/s1600/5_synthesize_property.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQpdSvbWjOGDuDQBa7w5vWffO8HHGVs4_dZAKWVIM4SgGAv_dHzp-6nEaMEHSJm9hEyi_VR29tcLd4bWKn_TtwgNvXDUHTlC1iMTzhII22qa5ARQwyYxfWQrWbmJnxrDwN-s0ECyt5OP8/s1600/5_synthesize_property.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
To finish setting up the outlet we need to connect it to the Map View. &amp;nbsp;Open MainStoryboard.storyboard, right click on the View Controller and drag from the mapView under outlets to the MKMapView. &amp;nbsp;This is what the pop up should look like when you are finished.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi1V-HOo6SknkfWdTU7hDd_-4duVWzbeVAMNjKsydB5xhERSFvPIRoDjzfr7phKD51D5JnH-37iD4RFGiLDwVoje1Uw-n68PK4ulUvpoxPWiJBVnwVqYCuNfV9rX92WJbyn9kEUxVCz_0/s1600/5_connect_outlet.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi1V-HOo6SknkfWdTU7hDd_-4duVWzbeVAMNjKsydB5xhERSFvPIRoDjzfr7phKD51D5JnH-37iD4RFGiLDwVoje1Uw-n68PK4ulUvpoxPWiJBVnwVqYCuNfV9rX92WJbyn9kEUxVCz_0/s1600/5_connect_outlet.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
We also need to set the MapView delegate to the ViewController class. &amp;nbsp;Right click on Map View and from the pop up drag from the delegate under outlets to the View Controller.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNUDvEXjcvSbbJY59ux-BLVrULfS5VMy7xOrVWFZPZAwpWXCu5a-sncHiswKh_9fTVJkJJFsJ2VZV9VwqanDDvQ8Za-OuCalpcQqyJyN7FNYWvLzvLlkUzZohFjtigXQXqQmGKI05COWw/s1600/5_set_delegate.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNUDvEXjcvSbbJY59ux-BLVrULfS5VMy7xOrVWFZPZAwpWXCu5a-sncHiswKh_9fTVJkJJFsJ2VZV9VwqanDDvQ8Za-OuCalpcQqyJyN7FNYWvLzvLlkUzZohFjtigXQXqQmGKI05COWw/s1600/5_set_delegate.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
If the delegate of MKMapView is set to the ViewController class, the class needs to implement the MKMapViewDelegate protocol. &amp;nbsp;Open ViewController.h and add &amp;lt;MKMapViewDelegate&amp;gt; at the end of the @interface line.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgON4EhyphenhyphenuNdwwSdHRW5TPSNJidYBbRlga8YMhYbu-_bbxrm_EKLkXXBJCgcoGXd2fQzAa0VraagLYm-2vhWRZ9W8bBTVh236Igfbw5kuh3ZqQKDpWDNvNlqVql3IIwm9N6yfWK7nV7Wbo/s1600/5_add_protocol.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgON4EhyphenhyphenuNdwwSdHRW5TPSNJidYBbRlga8YMhYbu-_bbxrm_EKLkXXBJCgcoGXd2fQzAa0VraagLYm-2vhWRZ9W8bBTVh236Igfbw5kuh3ZqQKDpWDNvNlqVql3IIwm9N6yfWK7nV7Wbo/s1600/5_add_protocol.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
All that is left to do is to set the showUserLocation property for the mapView to YES, and implement the method of the protocol that tells us when the location was updated. &amp;nbsp;Open, ViewController.m and add [self.mapView setShowsUserLocation:YES]; to the viewDidLoad method and implement -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation &amp;nbsp;When the location is updated the map zooms to the new region.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5fXYGZjSVnoJV61jC2GMiTuNzUDrIGSvfDS-fcp__PQpxra9XrYKUH1-yL5Fm3aPwgiVUyw_fLW1WBDf7dqr4R7sa1V3TQI5pjlXpIp2dix7NgWZ8KxoMfGHsctzs9x8Q_A6zZFAc7O8/s1600/5_update_region.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5fXYGZjSVnoJV61jC2GMiTuNzUDrIGSvfDS-fcp__PQpxra9XrYKUH1-yL5Fm3aPwgiVUyw_fLW1WBDf7dqr4R7sa1V3TQI5pjlXpIp2dix7NgWZ8KxoMfGHsctzs9x8Q_A6zZFAc7O8/s1600/5_update_region.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Press the Run button or go to Product-&amp;gt;Run.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDxe0uHYmGsRNRBf5V16KXDzaufgPGEWk1zcSifhHsR8zh-9Cu-thzeFKfpuT452RbOqDUnm-HYS-OvTrIoluMbsfB-cn1aTMNSTK17T3yqRLHL8sPabOQ3qz4z6p17t-Uxd8FQiE-reY/s1600/5_finished_app.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDxe0uHYmGsRNRBf5V16KXDzaufgPGEWk1zcSifhHsR8zh-9Cu-thzeFKfpuT452RbOqDUnm-HYS-OvTrIoluMbsfB-cn1aTMNSTK17T3yqRLHL8sPabOQ3qz4z6p17t-Uxd8FQiE-reY/s1600/5_finished_app.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
You can simulate the location in the simulator and the map is updated and zoomed to the new location.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDpEwK2IQlIE-K3uTc1ZgT-c1cRc-vPsFXlO1RUwRIQ35vGbT3npi7mPM57zARl4R4c_RFvxEhehkxaR64hqfNVK4EHMajJ8zOKQG29fXsoQNTyoBJ5vNYrKBkkcQe9DoL1EzqI4OZ-yA/s1600/5_simulate_location.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDpEwK2IQlIE-K3uTc1ZgT-c1cRc-vPsFXlO1RUwRIQ35vGbT3npi7mPM57zARl4R4c_RFvxEhehkxaR64hqfNVK4EHMajJ8zOKQG29fXsoQNTyoBJ5vNYrKBkkcQe9DoL1EzqI4OZ-yA/s1600/5_simulate_location.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
You can download the code used in this tutorial from&amp;nbsp;&lt;a href=&quot;https://github.com/code-and-coffee/FindMe&quot; target=&quot;_blank&quot;&gt;github.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
For more details on how to take advantage of MapKit and iOS &lt;a href=&quot;http://amzn.to/LIupIU&quot; target=&quot;_blank&quot;&gt;iOS Programming: The Big Nerd Ranch Guide (3rd Edition)&lt;/a&gt;&amp;nbsp;is a great resource.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please support this blog by making your next&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/?_encoding=UTF8&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;linkCode=ur2&amp;amp;tag=httpcodeandco-20&quot; target=&quot;_blank&quot;&gt;Amazon&amp;nbsp;purchase from this link&lt;/a&gt;

or consider donating in bitcoins:
&lt;div&gt;
  &lt;a href=&quot;bitcoin:1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&quot;&gt;1NxsuZtusbk5HZ4RuSKaibRZkbJks8fQNS&lt;/a&gt;
  
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://code-and-coffee.blogspot.com/feeds/1742471167723872031/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://code-and-coffee.blogspot.com/2012/07/getting-started-with-mapkit-and-ios.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/1742471167723872031'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3770203940285232860/posts/default/1742471167723872031'/><link rel='alternate' type='text/html' href='http://code-and-coffee.blogspot.com/2012/07/getting-started-with-mapkit-and-ios.html' title='Getting Started with MapKit and iOS'/><author><name>Nick Petrov</name><uri>http://www.blogger.com/profile/16119717188780438388</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5ISabaOyb4HbqZr1_QaqdwOPP7BgTOjkTAMtFACkTmvNqQWnVkLP2kuYg8I9Wx99HK884VAAEvOzMLIrk3bnlLjukTaTaI2tEbFoo17NzKd0OFCKSpFBONUi9ZBggsx1nHrdok5ozOts/s72-c/5_new_project.png" height="72" width="72"/><thr:total>1</thr:total></entry></feed>