{"id":334,"date":"2011-02-21T13:36:56","date_gmt":"2011-02-21T19:36:56","guid":{"rendered":"http:\/\/benincosa.com\/blog\/?p=334"},"modified":"2014-11-19T11:25:16","modified_gmt":"2014-11-19T17:25:16","slug":"welcome-to-iphone-development","status":"publish","type":"post","link":"https:\/\/benincosa.com\/?p=334","title":{"rendered":"Welcome to iPhone development"},"content":{"rendered":"<p>Last year I learned Ruby and Ruby on Rails.\u00a0 So in keeping with that good advice to learn a new program language every year, I thought this year I would tackle objective C and Apple&#8217;s IDE (xcode).\u00a0 Why not?\u00a0 iPhones are fun and the only reason I was able to talk my wife into letting me fork out the money for a Mac was because I told her I wanted to write iPhone apps.\u00a0 Well, 3 years later and I&#8217;m finally doing it&#8230;<\/p>\n<p>So here&#8217;s how I&#8217;m starting:<\/p>\n<h2>Resources<\/h2>\n<p>As I&#8217;ve been researching the best book to buy or examples to find, I&#8217;m always struck by how readily information is available to any seeker of wisdom.<\/p>\n<h3>Books<\/h3>\n<p>There are lots of books about iPhone development and I read the first chapter of several of them.\u00a0 I ended up accidently clicking the <span style=\"font-family: verdana,arial,helvetica;\"><strong>Beginning iPhone 4 Development: Exploring the iOS SDK <\/strong><\/span>from Amazon which I suppose wasn&#8217;t bad since it seems to be the top recommended book.\u00a0 The book will probably arrive sometime this week.\u00a0 But as I checked out the first chapters of the one by the Big Nerd Ranch, I really liked how they presented and explained things.\u00a0 So that&#8217;s it for books.\u00a0 O&#8217;Reilly has a deal today as well for $13 for a book called Cocoa &amp; Objective-C: Up&amp;Running .\u00a0 Its $14 with the 50% discount code of DDCRN. There seems no shortage of people who want to tell you how to code for the iPhone as long as you are willing to pay for it.<\/p>\n<h3>Apple Resources<\/h3>\n<p>I was able to download from Apple&#8217;s iBook store the free <em>iOS Application Programming Guide<\/em>, which was actually pretty well written and I&#8217;m sure I&#8217;ll go back to.\u00a0 It is about 333 pages and tells how apps run on an i* device.\u00a0 Many of the concepts I&#8217;m sure I&#8217;ll forget but hopefully when I run into a serious bug I&#8217;ll come back to it and say doh!\u00a0 its cause of _______.\u00a0 I actually really like this doc (for now) as it provides a theory which is something a person who already knows how to program needs to get familiar with to get up and running on this platform.\u00a0 This is a huge recommendation.\u00a0 There are also several other Apple docs referenced in this pdf file that shouldn&#8217;t be overlooked.\u00a0 Included in this is &#8220;The Objective-C\u00a0 Programming Language&#8221;<\/p>\n<h3>Videos<\/h3>\n<p>Here was where the real treasure chest was found.\u00a0 The course given at Stanford university is offered on <a href=\"http:\/\/www.youtube.com\/watch?v=oesNwgHn1ws\">YouTube<\/a> and is also available from iTunes complete with power point documentation.\u00a0 Watching the last half of the first class and I already created my first app with a slider that changes a label.\u00a0 The Stanford class doesn&#8217;t use any books and instead references Apple documentation.\u00a0 It seems to be a great way to start learning. I figure if I do one lecture a day (or 1 every two days where I follow along ) then I&#8217;ll be in very good shape.<\/p>\n<h3>Other Online Resources<\/h3>\n<p>In addition to iTunes U and YouTube there are countless other sites where people freely share information.\u00a0 Just google the class you want to know about and you&#8217;re there.\u00a0 But how can you beat getting taught from Stanford professors who are also employees of Apple?<\/p>\n<h2>The first program<\/h2>\n<p>So after using xcode and generating the slider demo from the Stanford class I thought I&#8217;d first just try to compile using good old gcc and a basic program.\u00a0 There was a good wiki article that explained the history of the language.\u00a0 One of the important things I read was: &#8220;In Objective-C one does not <em>call a method<\/em>; one <em>sends a message<\/em>&#8221; so as a future reference, I have to remember that objects are sent messages to run what would be a method in most normal OOP languages.\u00a0 The\u00a0 other few important things:<\/p>\n<ul>\n<li>Classes are declared in header files and methods are implemented in the *.m files (which used to stand for messages)<\/li>\n<li>In the header file a (-) in front of a method means its an instance method.\u00a0 A (+) in front of the method means its a class method (similar to how in Ruby we do a self.foo)<\/li>\n<\/ul>\n<p>So here&#8217;s a program named\u00a0 nothing.m that does nothing:<\/p>\n<pre>#import &lt;Foundation\/Foundation.h&gt;\r\n\r\nint main(){\r\n return 0;\r\n};\r\n<\/pre>\n<p>Then, I just compile it on the command line:<\/p>\n<pre>gcc -framework Foundation nothing.m -o nothing\r\n<\/pre>\n<p>Running nothing:<\/p>\n<pre>.\/nothing\r\n<\/pre>\n<p>Not very interesting, but hey, its a program and it did what you told it to do.\u00a0 You can then get fancy and add a printf or something else.\u00a0 But from here on out, I&#8217;ll probably be in xcode as that seems to be what all the cool kids are doing.<\/p>\n<p>What are some important beginner tips you have?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last year I learned Ruby and Ruby on Rails.\u00a0 So in keeping with that good advice to learn a new program language every year, I thought this year I would tackle objective C and Apple&#8217;s IDE (xcode).\u00a0 Why not?\u00a0 iPhones are fun and the only reason I was able to talk my wife into letting&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[28],"tags":[108],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/334"}],"collection":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=334"}],"version-history":[{"count":4,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/334\/revisions"}],"predecessor-version":[{"id":2799,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/334\/revisions\/2799"}],"wp:attachment":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}