Learn Objective-C: Day 1

Learn Objective-C: Day 1

Tutorial Details
  • Technology: Objective-C
  • Difficulty: Beginner
  • Completion Time: 30 - 60 Minutes
This entry is part 1 of 6 in the series Learn Objective-C

Welcome to my series on coming to grips with the awesome language that is Objective-C. Throughout this small series of articles, my aim is to take you from no prior experience with Objective-C to using it confidently in your own applications. This isnʼt a rush job – so donʼt expect to just skim through the basics and be away – weʼll be going through not just the bare essentials, but also the best practices you can apply to ensure your code is the best it can be. Letʼs jump straight in!

What is Objective-C?

If youʼre reading this series then Iʼll hazard a guess that you already know, but for those of you who donʼt, donʼt worry as by the end of this part youʼll know what it is back-to-front and inside-out.

Objective-C is an object oriented language which lies on top of the C language (but I bet you guessed that part!). Itʼs primary use in modern computing is on Mac OS X as a desktop language and also on iPhone OS (or as it is now called: iOS). It was originally the main language for NeXTSTEP OS, also known as the operating system Apple bought and descended Mac OS X from, which explains why its primary home today lies on Appleʼs operating systems.

Because Objective-C is a strict superset of C, we are free to use C in an Objective-C file and it will compile fine. Because any compiler of Objective-C will also compile any straight C code passed into it, we have all the power of C along with the power of objects provided by Objective-C.

If youʼre a little confused at this point, think of it this way: everything C can do, Objective-C can do too, but not the other way around.

What will I need?

Throughout this series, we will not focus on building applications for the iPhone. Instead, we will concentrate more on the language itself and for this reason all you will need is a Mac with a compiler such as GCC. If youʼve installed the developer tools from Apple (Xcode, Interface Builder, etc), then GCC should already be installed. If not, then head to Appleʼs developer website and get yourself a free copy.

As far as prerequisites go, while I donʼt expect you to have a full background in computer science, some knowledge of programming in general or of C in particular would definitely be a bonus. If you donʼt have much prior programming experience, donʼt worry -youʼll pick it up in no time!

If youʼre running Windows (which is unlikely as this tutorial is aimed at iPhone developers) you can still compile Objective-C on your system using a compiler such as CygWin or MinGW. This tutorial series is catered to Mac users, but if you are using Windows and encounter any problems then be sure to leave a comment and Iʼll see if I can help.

Compiling your code

Before you can see your code in action, you need to be able to compile it into something executable. Hopefully you now have your copy of GCC ready. Compiling is really easy, a simple one line command.

NOTE:
Compiling is the process of “translating” a high-level computer language, like Objective-C or PHP, into a low-level machine code that can be processed by a computer when the program is executed.

All the programs that we see running in our fancy Mac OS operating system consist of a series of instructions that are visually displayed to us in a GUI, or Graphical User Interface. In contrast to the GUI program interaction with a mouse that most of us are familiar with, it is possible to issue commands directly to the operating system through a text-based interface known as a “terminal” or “command line.”

The command line application in Mac OS is called Terminal and can be found in Applications -> Utilities. Go ahead and open Terminal now (you can also search for it in Spotlight). Terminal has several basic commands you should be aware of in order to properly utilize it. One of the most important commands to know is cd, which stands for “change directory.” This command allows us to change where in the filesystem Terminal is reading from. We canʼt just tell Terminal to compile our file if we donʼt show it where the file is first! To switch to a desired directory, you can use a full path such as:

cd /Users/MyName/Desktop/Test

You can also use relative paths, allowing you to only type a single folder name in some cases. For example, if youʼre already in your Desktop folder, you could simply type:

cd Test

to get to the Test folder.

What if you want to see where you currently are? The immediate folder name is displayed before the prompt (the bit where you type). For example, if your prompt says Dan- Walkers-MacBook: Desktop iDemonix$ I can assume Iʼm in the Desktop folder. If you aren’t sure, you can also type pwd to display the absolute filepath of the current location.

If you want to list what files and folders are in the current folder, use the list command: ls. Finally, if you wish to go up a directory to a parent folder, type “cd .. “. So, if we were in the Test folder, which is inside the Desktop folder, but we wanted to go to the Desktop folder instead, we could type cd .. to go up to the parent directory, Desktop. If we wanted to get to the home directory we would type cd ../.. to go up two levels. Alternatively, to get to the home directory you can just type cd ~ from anywhere.

When using the Terminal application, compiling looks like this:

gcc inputfile.m -o outputfile

Youʼve probably already guessed how it works: inputfile.m contains our code (.m is the extension used for Objective-C files) and -o tells gcc we want our executable to be called whatever we specify next, which in the example above is outputfile. To run our creation after compiling, we simply type:

./outputfile

Simple.

When you compile, the compiler will generate any errors, notifications or warnings related to the syntax of your code. Errors generated when compiling are understandably referred to as “compile-time” errors, and this is often the most stressful part of writing an application (especially when your code isnʼt compiling because you put a single character in the wrong place or forgot to end a line with a semi-colon). Compiling can also take time when youʼre writing large applications consisting of multiple files, which is also another reason why compiling can be a tedious experience. This fact has led to a ubiquitous programmer joke often seen on the t-shirts of men with unkempt beards: “I’m not slacking off. My code is compiling.”

The Basics

Objective-C itself isnʼt that hard to learn. Once you get to grips with the basic principles, you can pick the rest up as you go along pretty easily. You do need to have an understanding of the fundamentals of C programming though, and that is what the rest of this tutorial will cover.

Letʼs look at a basic application in C:

#include <stdio.h>
int main(){
    printf("Hello World\n");
    return 0;
}

All this application will do when you run it is display the string “Hello World” in Terminal and exit.

NOTE:
Curious about the “return 0″ statement? Because we told the compiler that the function main() will return an integer, we return the constant integer value ’0′ at the end of the function. By convention, returning ’0′ signals to the calling program that our program finished execution without any errors.

To try this for yourself, fire up Xcode and make a new Objective-C class. Delete all the code Xcode gives you by default and stick the above code in. Once youʼve done that, you can compile it using Terminal. Open Terminal and change to the location where your file is, if you saved to the desktop then simply type cd desktop so that Terminal is now reading from your Desktop. Then type this command:

gcc program1.m -o program1

Your program should compile with no errors. To run it, simply type:

./program1

Then hit return.

Awesome, so what actually happened there? Well, first we imported a library called stdio which manages the standard i/o (input output) functions, like printf(). We then create a function called main which should return an int or integer which is basically a number with no decimal point. We then use the printf() function to output ʻHello Worldʼ in to terminal. The \n we use tells Terminal to put a newline after the text. Finally, we return 0 (remember we said main should return an integer) which tells the operating system everything went fine. We use the name main because this is triggered automatically when the program is executed.

So far everything should be pretty simple: we wanted to write some text to Terminal, so we imported a library with a function for writing text, then we used a function from that library to write the text. Imagine that what you import is a physical library and printf() is one of the books available.

Variables

Soldiering ahead, weʼre now on to variables. One of the fundamental things we need to be able to do in our applications is temporarily store data. We do this using variables, which are containers that can hold various types of data and be manipulated in various ways. We use variables to store all sorts of data, but we must first tell the compiler what weʼre going to store in it. Here are several of the most important variables that you should know about for now:

  • int – for storing integers (numbers with no decimal point)
  • char – for storing a character
  • float – for storing numbers with decimal points
  • double – same as a float but double the accuracy

When weʼre not using variables, weʼre often using constants. A constant will never change: we always know what the value will be. If we combine constants we get a constant expression, which we will always know the result of. For example:

123 + 2 = 125

This is a constant expression, 123 + 2 will always equal 125, no matter what. If we substituted a constant for a variable, the new expression would look like this:

123 + i = ?

Because i is a dynamic variable, we do not definitely know the result of this equation. We can change i to whatever we want and get a different result. This should give you an idea of how variables work.

One thing we still need to know is how do we display variables like we displayed “Hello World” above? We still use the printf() function, except it changes a little this time:

#include <stdio.h>
int main(){
    int someNumber = 123;
    printf("My number is %i \n", someNumber);
    return 0;
}

What weʼve done here is told the function printf() where we want our integer to appear, then where it can be found. This is different to a lot of languages such as PHP where you could just place the variable in the text.

We are not just limited to just one variable in printf(). The function can accept multiple parameters separated by commas, so we can pass in as many as we have formatting signs for in the text. Above we use %i as a formatting sign because we were including an integer. Other variables have their own format specifiers:

  • %i – integer
  • %f – float
  • %e – double
  • %c – char

One thing I want to touch on before we move on is the char type. A variable of type char can only handle single characters, when thatʼs all we need this is great, but if we need a string of text itʼs pretty useless. To get round this, we use something called a character array.

Imagine you have a sentence that is 11 characters long (like ʻHello Worldʼ – donʼt forget to include the space), a character array is like having 11 charʼs but all glued together. This means that the value of the character array overall is ʻHello Worldʼ but char[0] is ʻHʼ. In brackets is the char youʼre after, because we put 0 we get the first character. Donʼt forget that counting in arrays usually starts from 0, not 1.

Conditionals

When an application needs to make a decision, we use a conditional. Without conditionals, every time you ran your application it would be exactly the same, like watching a movie. By making decisions based on variables, input or anything else, we can make the application change – this could be as simple as a user entering a serial number or pressing a button more than 10 times.

There are a few different types of conditionals, but for now weʼre just going to look at the most common and basic: the if statement. An if statement does what it sounds like, it checks to see if something is true, then acts either way. For example:

#include <stdio.h>
int main()
{
    if(1 == 1) { // This is always true
        // Do some stuff here
    }
    return 0;
}

If 1 is equal to 1, then whatever is between the brackets is executed. You might also be wondering why we used two equals signs instead of one. Using two equal signs is an equality operator, which checks to see if the two are equal to each other. If we use a single equal sign then weʼre trying to assign the first value to the second value.

Above, since 1 will always be the same as 1, whatever is in the brackets would be executed. What if we wanted to do something if this wasnʼt true though? Thatʼs where else comes in. By using else we can run code when the if conditional returns false, like so:

int main(){
    if(1==1){
        // Do some stuff here.
    }
    else{
        // The universe is broken!
    }
    return 0;
}

Of course, in real life, we wouldn’t be checking to make sure 1 is the same as 1, but the point is made. Consider an application that closes if you press the close button three times (annoying but relevant). You could check in the brackets to see how many times it has been pushed. If it is lower than 3, then your else block could execute code to tell the user how many more times the button must be pushed to exit.

Weʼll look at conditionals more when we come to use them in our applications further along in the series.

Loops

Now let’s investigate a programming loop. Loops, as the name suggests, let us loop through a piece of code and execute it multiple times. This can come in very handy in situations such as populating a list or repeating a piece of code until a conditional returns true.

There are three types of loops, in order of most common: for, while, and do. Each one is used to repeat execution of a block of code, but they function differently. Here are examples of each:

// if loop
int main () {
    int i = 9;
    int x = 0;
    for (x = 0; x < i; x++){
        printf("Count is: %i\n", x);
    }
    return 0;
}

This may look a little complex at first, but it really isnʼt. In the parentheses after for is the initiator, a conditional, and the action. When the for loop starts it executes the initiator, which in our case above sets x to 0. Each time the loop runs (including the very first time) it checks the conditional, which is "is x smaller than i?" Finally, after each loop through the code, the loop runs the action - which above increments x by one. Simple. Since x is increasing by one each time, x will soon no longer be less than i and the loop will finish and the program will carry on running.

// while loop
int main () {
    int x = 0;
    while (x < 10){
        printf("Count is: %i\n", x); //Watch OUT! Something is missing.
    }
    return 0;
}

Similar to the for loop, the while loop will execute the code between the brackets until the conditional is false. Since x is 0 and we don't change it in the code block, the above would run forever, creating an "infinite loop." If you wish to increment x, then in the case of our while loop you would do this between the brackets:

// while loop
int main () {
    int x = 0;
    while (x < 10){
        x++;
        printf("Count is: %i\n", x);
    }
    return 0;
}

The do loop is essentially the while loop, except the conditional runs after the block of code. What this means is when using a do loop, the code is guaranteed to run at least once:

// do loop
int main () {
    int x = 0;
    do {
        x++;
        printf("Count is: %i\n", x);
    } while(x < 10);
    return 0;
}

Pointers

Pointers can cause a lot of confusion with newcomers to programming or just newcomers to C. It is also not immediately clear to some people how they are useful, but youʼll gradually learn this over time. So, what is a pointer?

As the name implies, pointers point to a location. Specifically, locations in computer memory. Think of it like this, when we create a variable (let's say it's an integer called ʻfooʼ as is so popular with programming theory) and give it a value of, for example 123, we have just that - a variable with a value of 123. Now, if we setup a pointer to foo, then we have a way of indirectly accessing it. That is, we have a pointer of type int that points to foo which holds the value '123.' This would be done in code like so:

    int foo = 123; // This is an integer variable
    int *ptr = &foo; // This is a pointer to an integer variable

Clear as mud? Donʼt sweat it. Pointers are hard - often considered the hardest thing to learn when picking up the C language. Pointers will eventually become second nature to you though, and there will be more on pointers within Objective-C further in this series.

Wrapping Up

You've just been given a crash-course overview of the C language fundamentals. This part of the series was intended to be a quick primer on C to get you ready and prepared for the rest of the series, and should have been especially useful to those who are already familiar with programming in another language. If you are new to programming in general or are still in doubt about any basic of C, re-read the above and feel free to leave questions in the comments.

Before next time, be sure to try and compile your own programs using the code above. Set yourself small challenges, such as making a loop execute 10 times and count each time through the loop using printf. Thereʼs no harm in trying and experimenting, if it goes wrong then itʼs probably even better as itʼll get you on the right track to troubleshooting your own code.

Challenge

For this week, we will end on a simple challenge. You are to create three programs that count to 10 using each type of loop. Since we will use loops often in Objective-C, itʼs good that you learn to create them by heart. That should be pretty easy, so try to count down from 10 to 1 afterwards (if ++ increments by one, what could be the code to decrement by 1?).

Next Time

In the next installment of this series, Iʼll provide an overview of how Objective-C works. Weʼll also look at object orientated programming and its uses, as well as really drill down into classes, instances, methods, inheritance and more.

Next week should really help you to understand what makes Objective-C such a great language and why it really extends the C language in so many useful ways.

Any Questions

If you have any questions, you can either leave a comment below where Iʼll try and keep checking or you can shoot me a message on Twitter (http://www.twitter.com/iDemonix) where Iʼll get back to you ASAP.

Series NavigationLearn Objective-C: Day 2»

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • shumaila Batool

    hello! well i am in my final year now and i thought i would do my final year project in RF or some other field! but now i have decided to do my project in iOS.. i know C++ and C language but i am not too sure if i will get the concepts now:/ since i never had an idea of changing my field:/ in how much time i will be able to develop a game if i satrt working hard and learn from the internet? since there is no other source and my university does not teach any iOS related subjects or session etc! plz help!

    • peter ze pan

      If you know, C+ and C the step to Object C is like you read this tutorial in 1 day and your done.

      The IDE (XCode) is AWSOME.. It allows you to make a simpel app in 1 second. Tho alot of frustation in the beginning.

      To learn the IDE I did Follow this dude:

      http://www.youtube.com/user/AppleiDev

      Also i rec to get a MAC cuz there is no PORT for Xcode to Unix or for Windows.

      To safe some bucks, make an HackIntTOsch. This means you actually install an mac on a Intel Platform..

      Hope this kinda helped you out,

      Cheers.

  • Oneminutwonder

    WOW awsome guide,

    I programmed C++ al my life, since i got a Mac now, i wanted to play around with Xcode. I readed some other Tutorials allready but yea they lack the parts of Properties etc etc.

    Cheers,

  • evan

    interested in learning objective c from your illustrative course.
    But cannot download the , Appleʼs developer website and get yourself a free copy, url that is in your text at the start! in order to get my Gcc compiler
    all that happens is that i go around in circles such as adverts, other apps and signing. in and then
    told my ios is out of date – mine is the latest update.
    would you give me a straight link to a proper site that enables me to download this free , without any fuss, so that i can carry on with your site.
    i hope this is in order thanks

    reg Evan

  • http://www.google.ae Mohammed

    Hi Teacher,

    I really appreciate your great, excellent and nice job. It really helps me. I am stuck with only one thing; how to apply what i’ve learnt in the Xcode. I don’t know how to try with Xcode. and I don’t have the gcc compiler. I tried to get it from the internet but unfortunately I got tired. Even when I tried to copy the Hello World app.

    Thanks in advance.

    Best Regards,
    Mohammed Khaled
    Abu Dhabi
    UAE

  • Andrew

    I was working through the tutorial when I got stuck and couldn’t use the gcc compiler. the terminal responds with -bash gcc: command not found. I’ve updated my xcode to it’s latest version and through google but could not find a resolution. Please address this problem. It would help a lot thanks.

  • jaidev

    Hello sir,
    Is xcode and mac is necessary to run the codes , i have Intel processor with Ubuntu now how i proceed further to run the codes in Intel only ,is this codes are runnable on netbeans or eclipse suggest me???

  • Andrew

    Got it to work. Went to Xcode>Preferences>Downloads and downloaded the command line tools for the IOS 5.0 simulator.

    • Grace

      I did the same; but how do you access GCC afterwards?

  • Linish

    Nice Tutorial. Looking forward through the rest of the turorial series of this :)

  • http://www.techstarvation.wordpress.com/ Sumit Gupta

    Good work.

  • http://www.facebook.com/hatem.alimam Hatem Alimam

    a great series, but I’ld like to make a point just so no one would be confused, PHP is not compiled language ,The PHP language is interpreted The binary that lets you interpret PHP is compiled, but what you write is interpreted. You might put another example which is Java, Java is a compiled language.
    Thanks.

  • Sophie

    I downloaded xcode and I’m able to follow these directions up until the point where i have to use the gcc command. at that point Terminal tells me -bash: gcc: command not found What do I do?

  • vince

    hi, im a windows user and i downloaded MinGW and i did first part for example cd/MyName/Desktop/Test
    trying to figure out wat i did wrong if u could help me i would greatly appreaciate it

  • vince

    it keeps telling me: No such file or directory

  • turd

    to make gcc work: install Xcode, start it, Preferences->Downloads->Command Line Tools->INSTALL

    • Rob

      Thanks.

  • Manjeet

    Hi, I am Manjeet, I like your way to make Objective c More easy.. I already study c and c++ but I am new in Objective c..And I want to learnt it. So please help me…I have a question Is C codes and objective c Code have same..Like you show in day 1…

  • vaishali

    nice article.

  • tarn

    Awesome job, Dan. Really helpful!! I was wondering to buy a book for learning Objective C. And i found out the book – Objective C – The Big Nerd Ranch. I don’t have any experience about programming. So, i want your opinion. Whether I should buy this book or something else. Any help will be kindly appreciated.

  • Mitch Moccia

    Hugely helpful. Not only is this tutorial beautifully written, it also gives you just enough learning space so you can discover the glue that binds for yourself. For example, Dan comes out and says “create an Objective C class” with no explanation of how to do that. Had to snoop and figure it out, great learning moments here.

    @tarn The book “Objective C – The Big Nerd Ranch” is also extremely helpful and highly recommended in addition to this tutorial series, and it’s half price on the Amazon Kindle store.

    @sophie From Xcode go to Preferences > Downloads > and install Command Line tools
    I did this and could immediately run the compiler from my Mac terminal.

    Thanks again to Dan for this life changing tutorial.

  • JokeLand

    Hi, I’m not born yet but i allready dev with ton of skill. ty for this refresh

  • Manjeet Singh

    I am not able to find Terminal in mac System. I am new with mac system.

    • k

      go to launchpad- then others and click on terminal

    • veggiedude

      Look for the “magnifying glass” icon in the far right corner of the menubar. This is Spotlight. Click on it and type in TERMINAL and it will be found.

  • cbird

    Thanks for the tutorial. I am a little confused about what the int main( ) line is actually doing. I’m brand new to programming in any language, but what I think I understand is that the int main ( ) is referencing a directory within the compiler??

    • Tim

      Let me see if I can help you. In “int main( )”, the int word is the return type of the function(or method if you prefer) called main( ). You can tell its a method because of the parentheses. This is stating that main( ), which is an Objective C method that automatically runs when you execute the program, returns an integer value(1, 2, 3, etc). Hope that helps! Try to find an API for Objective C…it will show you what methods each class has available for you to accomplish certain tasks.

  • sunjen

    I’m new to the mac so I’m taking it slow.. coming from the pc, the mac feels like it was created by Yoda, need to unscramble where things are, how to navigate…

    • Peter

      iClouded your future is

  • alifarooq

    Challenge

    int main () {

    int x = 10;

    do {

    x--;

    printf("Count is: %in", x);

    } while(x > 0);

    return 0;

    }

    • http://www.facebook.com/abhimanyu.banerjee2 Abhimanyu Banerjee

      it will print 9 to 0 in descending order

    • Ahmed

      9 to 1

  • Jacko

    I am a complete beginner and forgive me for not quite understanding but where to tutorial says “fire up xCode and open a new objective-C class” does this beginning a new project, and if so which project type should I select? I cant generate a .m file from the command line project and ‘gcc’ wont compile the .m file of an application project.

    Thanks

    • Grace

      Hi Jacko, I just figured this out myself :) so don’t worry you’re not alone.

      When you open Xcode ignore the prompt to create a new project, etc.
      Go to file at the top of the screen, go to new, and then select file under new.
      From there select Objective-C class which should be automatically highlighted already and hit next.
      Name it and save it under desktop or any other directory, just remember which it is.

      You should be able to use the .m here

      I hope that helps!

  • Soumya

    I am using windows 7 OS,what software i install forobjective-c.

  • DexRay

    Hello, im 13 and no experience with other programming languages and im currently struggling to understand something to do with the loops : on the first “for” loop. You say that the program will continue running and obviously the x integer will become bigger that the i integer. Do you mean that it will stop before becoming greater than the i integer. My loop stops at 8.

    Thanks for the guide.

    • S

      Hey Dex , there are many different ways to look at for loops, ill show you the way I do it (this is also a very common way). There are really only 2 major things to pay attention to in a for loop, where it starts, and where it ends. Also I prefer to declare my variable and initialize it in the for loop. Example:
      for ( int x = 1 ; x <= 10 ; x++ ){
      printf ("% in", x );
      }
      This should print out the numbers 1-10. So here I know my loop is starting at 1 and ending at 10. Hope this helps good luck!

  • Guest

    Getting started with this AWESOME guide…!!! Thanks

  • Geekyks

    Getting started with this AWESOME guide…!!! Thanks

  • Grace

    Hi, I believe Jacko asked a similar question earlier, but there was no response: I’m confused about the part where it says to fire up xcode and make a new class. I have Xcode started, and it prompts me with what I want to do and what template etc. What should I select?? Completely lost after “firing up Xcode” because I don’t know where to go. ): Please help me.

    Thank you!

  • Grace

    Hey, I’m new to this, and I finally figured out what to do after “fire up Xcode” from searching the comments, and now I’ve hit another obstacle! I’m sure I did everything I was supposed to do. I went to Xcode, file, new file, objective-c class, named it project1(I know this doesn’t matter, but I figured I couldn’t go wrong staying strictly to the directions) (I also stuck with NSObject for the subclass because it didn’t say otherwise), created it under desktop, staid on “project1.m” side and replaced code given by Xcode with the tutorial code, opened terminal, typed cd desktop, gcc project1.m -o project1 to which I received errors. I dismissed these and hoped it would work anyway, but this is what I ended up with:

    Last login: Sat Feb 16 23:01:53 on ttys000

    graces-macbook:~ grace$ cd desktop

    graces-macbook:desktop grace$ gcc program1.m -o program

    program1.m:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token

    program1.m:10: error: expected identifier or ‘(’ before ‘{’ token

    graces-macbook:desktop grace$ ./program

    -bash: ./program: No such file or directory

    graces-macbook:desktop grace$

    Someone please tell me what I did wrong. I’m desperate; I really just want to learn this, but I keep encountering tiny problems, and it’s really frustrating when I can’t find any help. It seems like people who mention their age get more help….are you going to reduce me to telling my age on a comment board??
    Hopefully not :3 Thank you!

    • Grace

      Also, I realize I accidentally said “program” instead of “program1″, but when I reran it with “program1″ I got the exact same errors; so sorry about that.

    • S

      Hey grace! Dont get discouraged, we all go through programming nightmares, just jeep a thick skin and dont give up! It happens to everyone.To be honest I have no idea why this tutorial is having you compile with the terminal in xcode. Apple ios is an extension of another operating system called linux which is why the use of “gcc” and on linux you would need the terminal. On xcode in order to compile your program all you need to do is click the “build” button at the top left side of your xcode Window. Your term should pop up and show the code working, if it doesnt, just open the term and click build, then youll see it working. As far as your other errors, without seeing the code its hard to tell, but double check your syntax. Make sure you have a ; at the end of each executable statement (ex printf (“hello..”); hope that helps and hang in there!

      • Grace

        S, Thank you. Are there any steps I should change before that? Because there is no Build button anywhere–there is one under the “Product” drop down at the top of my Mac screen, but it doesn’t allow me to press it, so I think I must be in the wrong part of Xcode? Did I “make a class” correctly? Thanks for helping, and I’ll try not to get discouraged :)

  • Seth’s world of programming

    You know what I’ll just stick with other languages for now

  • Tom

    Hi like a lot of others I’m 14. Every time I try loops in Terminal it tells me I made server all errors; undeclared, expected this, cannot find protocol….. How can I solve this? Thank you.

  • Young Developer

    Can i have thats Tutorials in a PDF document?

  • pixelBender67

    This is awesome, I’ve been wanting to get into some objective-c !!!

  • Retro

    Could you do a step by step (including all the little things like click this and open that)
    for starting up Xcode and how to compile it with Terminal.
    lukas asked the same thing, but the answer left me in the dust because
    where I’m at there is no “play” button

  • Julio Cesar Galvis

    Thank you for this tutorial. You make things easier for people starting to develop apps.

  • james

    hi
    sir my platform is windowS so i want to work on objective c plz help me?

  • amvita

    This is good. The only problem is it is difficult to get XCode on Windows when you dont have a Mac.
    any ideas, suggestions or help/advice would do.
    i am 13 btw and have finished basic c and almost c++
    thanks

  • http://www.facebook.com/john.curry.18 John Curry

    Hello, I am 104 years old, but my goal is to make an app before I die. I got lost on your first instruction! maybe it’s my alzheimers. but you said delete all the code xcode gives you and replace it with your code. The problem is you don’t specify which file needs to be deleted. All of them? just one? I assume it’s a .h file, but there are two .h files!!! help quickly, I feel a heart-attack coming on.

  • sorav palyal

    sir i have passed my +2 class and have some command on c language too. i want to be IOS DEVELOPER . so should i start objective c now? or anything else i have to do?because beore taking admission in an institute i want to have some basic knowledge so tell me which things i i must learn first……….please reply me.and one thing more i have only one month