4 36

Artikel ini sudah di baca 3946 kali!

So you’ve got a Mac, you’ve got an iPhone, and you really want to start writing some apps. There’s tons of documentation available, but the best way to learn a new language and framework is to simply dive right in. All of the documentation and tutorials I ran across when learning to program the iPhone depended a little too much on Interface Builder, which basically sticks a layer of magic between me and what I want to do. Frankly, I like to begin at the bottom and work my way up, which is why this tutorial is going to show you how to create a basic ‘Hello World’ application programmatically – without the help of a visual designer.

When I pick up any new framework that includes a designer, I like to start out building interfaces in code, because then I get an understanding of what the designer is doing behind the scenes. And honestly, I find Interface Builder about one of the most confusing designers I’ve ever used.

The first thing you’re going to need to do is download and install the iPhone SDK. This is going to give you everything you need in order to build apps – XCode, iPhone Simulator, and Interface Builder. Downloading and installing the SDK is totally free. You’ll have to pay $99 if you want to run the app on a real iPhone or distribute it to the app store. For the purposes of learning, though, the simulator works just fine.

After you’ve got all that stuff installed, you’re ready to start. Start by launching XCode. By default it’s installed in the Developer folder.

When you launch XCode you’ll be presented with a welcome screen. You can either look through that or just dismiss it, none of it is particularly important. What we need is a new project. Select File > New Project to bring up the project templates.

The Window-Based Application is about as simple as it gets. What this template is going to give is a Window and an application delegate. An application delegate (UIApplicationDelegate) is an object that responds to messages from a UIApplication object. There can be only one UIApplication object, and the project template takes care of creating it for us. When you click Choose, you’ll now be prompted for a project name. I named mine “HelloWorld”.

Once the project is created, you’ll be presented with the XCode interface and all of the files the project template has generated for you.

The important files are main.m, HelloWorldAppDelegate.h, and HelloWorldAppDelegate.m. The main function is where the single UIApplication object is created. The function call


takes care of that. You might be wondering, though, how in the world is HelloWorldAppDelegate hooked up to the UIApplication object? Well, unfortunately there’s still a little magic we can’t avoid. The template created a nib file for us (MainWindow.xib) that takes care of forming this relationship. You’ll just have to take it for granted that the messages will be passed into our delegate. Now let’s check out the implementation of the delegate, HelloWorldAppDelegate.m. There are several messages we can get from the UIApplication object, however the template has already created the one we care about –


– (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after application launch [window makeKeyAndVisible]; }

This function is where we’ll be creating our view controller, which will eventually hold our ‘Hello World’ label object. In order to create a view controller, we need to add another class to our project that subclasses UIViewController. Fortunately, since creating view controllers is a common task, XCode has a template for it. Right mouse click on the Classes folder and choose Add > New File.

When you click Next, you’ll be presented with some options. The only thing you should have to set is the filename. I named mine HelloWorldViewController. You might notice that the new implementation file (HelloWorldViewController.m) is full of commented out functions. View controllers are meant to be used by overriding the base implementation of various methods. In our case, we want to override


About the author / 


Related Posts


  1. Make Apps September 18, 2013 at 7:05 pm -  Reply

    You may undoubtedly visit your comprehension of the job you are submitting. This sector desires more zealous copy writers just like you that are certainly not scared to convey the way they imagine. Always do ones cardiovascular.

  2. Make apps September 18, 2013 at 8:52 pm -  Reply

    That may be really attention-grabbing, You are a quite skilled digg. I’ve truly joined the rss and look toward trying to get more of one’s great submit. Also, I have provided your web site at my web sites

  3. bicycle Insurance Uk July 21, 2014 at 11:07 am -  Reply

    Thanks for sharing your thoughts about xcode.


  4. play minecraft free August 5, 2014 at 3:58 pm -  Reply

    Very nice write-up. I certainly love this site. Stick with it!

Leave a reply

Your email address will not be published. Required fields are marked *


POPULAR The most recent

  • Mac

    Cara Potong Video di Mac mengunakan Quick Time Player

    Artikel ini sudah di baca 23339 kali!Ekosistem Mac menyediakan QuickTime Player sebagai aplikasi default untuk menyaksikan video. Pengguna dapat menonton video dengan dua cara, melalui preview dengan hanya klik tombol spasi atau dengan double click untuk membuka video di QuickTime Player. Dikembangkan secara khusus oleh Apple, tahukah kamu bahwa QuickTime Player memiliki beragam fungsi tambahan? Bahkan, QuickTime Player dapat memotong…

  • Cara Membersihkan History dan Cache Pada Safari macOS

    Artikel ini sudah di baca 27735 kali!Berikut adalah cara untuk membersihkan riwayat (history) pada safari macOS : Buka Safari Di bar menu pilih History Pada daftar paling bawah, pilih Clear History Kamu dapat memilih rentang waktu riwayat yang ingin kamu hapus. Jika sudah memilih rentang waktu, klik Clear History Begini cara untuk membersihkan cache: Pada menu bar, pilih Preferences Di sisi kanan atas pilih…


Digital Ads


Yuk Buruan Follow akun dibawah berikut ini agar mendapatkan informasi yang lebih cepat dari Onno Sites

Stay up-to date with the latest news and other stuffs, Sign Up today!