How To Make iPhone Apps – Object Oriented Programming and Classes

Welcome to my series on How To Make iPhone Apps with no programming experience – where we’ll turn even the non-programmer into an iOS developer! Here’s the article index for the entire series in case you missed it.
In this article, we’re going through some basic but core programming principles that you’ll need to build iPhone apps.
If you’re coming from another programming language, then chances are you could probably advance to the next article. Otherwise don’t worry, read on and welcome to the wonderful world of programming!

1. Object Oriented Programming

The common understanding that non-technical people have about programming and coding is that it’s a series of commands and statements that tell the computer what to do. (At least, for the sample of people that I’ve asked!)

I never try to explain anymore than that because the explanation above works for them and that’s what they understand. That’s cool.

But if we’re about to build iPhone and iPad applications, I’m afraid that we’re going to have to get a little deeper than that!

The programming language we use to build iPhone and iPad apps is called Objective-C and it’s also a form of object oriented programming.

I’m going to borrow from Wikipedia here:

An object-oriented program may be viewed as a collection of interacting objects… In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent “machine” with a distinct role or responsibility.

Basically, the Wikipedia quote is saying that our program, or app, is just a bunch of objects interacting with each other.

Each object is defined by a “blueprint” which describes the characteristics of that object. But the blueprint merely describes the object.

In order to have an object with which we can use to perform tasks, we have to create an “instance” of it using the blueprint.

Think of the blueprint as a plastic mould. By filling the mould with plastic and allowing it to cool, we can manufacture an instance of an object.

When we’re building our iOS app, we’re essentially defining a series of blueprints for our objects, telling the program to create instances of objects and then issuing commands and statements for the objects to perform tasks and interact with other objects.

Got it? I know you got it.

Onward!

2. So What Is A Class?

You already know what this is.

It’s just the correct term for the “blueprint” that we’ve been talking about! So from now on, I’m going to say “class” instead.

In Objective-C, a class is defined with two files; a “.h” file and a “.m” file. There are various names for these two files, but we’ll stick with what Apple uses in their documentation. The .h file is called the “header” file while the .m file is called the “source” file.

So for example, if I were intending to write a class for a Superhero, I would have Superhero.h and Superhero.m.

The header file is where we tell other classes that interact with our class exactly what sort of interaction is available. You can think of the header file as a sort of public description of the class.

In Superhero.h (the header file), I would state what sorts of variables, properties and methods are available for other objects to interact with my Superhero. (More on variables, properties and methods farther down).

The source file however is where you implement the “guts” of the Class. This is where all of the code and logic of your Class goes.

In Superhero.m (the source file), I would write the code for what happens if another object actually called upon the variables, properties and methods that I defined in Superhero.h (the header file).

I want to remind you that the header file and source file, together, define a class and that a class is simply a “mould” or a “blueprint”. In our programming later on, we’ll be able to create instances of our class which we call objects. And we’ll make these objects interact with each other.

A few paragraphs ago, I mentioned that we use the Header file to specify what sorts of interactions our class would permit. I hinted at variables, methods and properties, so let’s take a closer look at what those are!

3. Variables To Store Things

You can think of a variable as a bucket to store a value of some sort. Once you declare a variable, you can set its value and retrieve it later on when you need it.

However, you must define the type of value that a variable can store and it can only store values of that type. You can even specify other classes as the type that you’d like to store!

Variables are essential to our programming because we’ll need to keep track of different objects, values and other data. We will keep track of this stuff by declaring variables of the correct type and we’ll use variables to help us keep track of these objects, values and data.

When we declare a variable in a class, your intention is probably to store some data that is related to that class.

In our Superhero.h file, we might declare a variable to identify and store our Superhero’s intelligence, stamina etc. Or we might even declare a variable with a type Superhero, in order to refer to our Superhero’s superpal!


What type of variables are there?
There are two broad categories of variables: value types and reference types. Then there are a whole bunch of variable types that fall into one of these two categories. Any variable which keeps track of objects is a reference type and the other ones are value types.

The good news is that this variable type terminology doesn’t vary too much from language to language (in terms of programming languages).

The bad news is that if this is the first time you’re seeing this, the variable type names won’t seem very intuitive to you!

Here are some of the common ones you’ll be using:
NSString
int
BOOL
double
[Classname]

NSString
With this variable type, you’ll be storing string data. In other words text! In most programming languages, text is thought of as a “string of text”, thus the variable type “string”. In Objective-C, it’s “NSString”. The extra “NS” is just something that Apple denotes their own classes with, so you’ll be seeing it again and again with other Apple classes. 

NSString is an Apple class, so remember that instances of classes are objects and variables that keep track of objects are reference-type variables. Later on, you’ll see that when we declare reference type variables, we’ll denote it with an additional asterisk (*) that we don’t have with value type variables.

int
“int” stands for integers. Did I just bring back memories from high school Math? 🙂
With this variable type, we store whole numbers. This is a value type variable.
BOOL
“BOOL” stands for boolean and this variable type can have only one of two possible values. “YES” or “NO”.
You can also assign it “TRUE” or “FALSE” or “1” and “0” but it means the same thing. 

You might be thinking, couldn’t we just represent this with a string or int type variable? You’re right, but if you know that the data you’re storing could only be one of two values, then by using a BOOL you would save memory and make your code less error-prone.

This is a value type variable.

double
With this variable type, we store decimal numbers. 

This is a value type variable.

Classname
I mentioned above that you can specify a class name as a variable type. When you specify a classname as your variable type, you can assign to that variable, an object of that class. 

This is a reference type variable.

Other types
There are way more variable types to introduce but let’s not get overwhelmed. We’ll introduce more as we need them. Let’s talk about methods!

4. Methods To Do Things

Think of methods as actions that we can call on to make an object do something. We define a method by giving it a name, what sort of variables we expect as input, what sort of result we will output at the end of the method, and finally the actual code and logic inside of the method!

When we declare a method in the header file of a class, we’re saying that other objects will be able to use these methods on instances of our class. You’ll be declaring your methods in the header file and writing the code to carry out the method in the source file.

In our Superhero example, I might declare a method called “Punch” in Superhero.h. In doing so, I’ll need to write the code in Superhero.m to make the Superhero object do something when the punch method is called.

5. Properties, What?

A property is sort of a variable and a method combined.

What??

OK, OK. I know it’s confusing but think of it this way:

A property is a method that sets or retrieves the value of a variable.

Well, then you might ask, “Why would I need a property if I can have variables that I can set or retrieve values from?”.

Well, you usually use a variable to keep track of something that you will use within your class. If your intention is to expose it for other classes to be able to set and retrieve, you’ll want to use a property.

Under the hood, a property still uses a variable to store the value you assign to the property.

In fact, it’s a best practice to declare a property for something that you want other classes to be able access or interact with.

This brings us to another point:

6. Public Versus Private

So far, we’ve been talking as if everything was public but when you declare something, you need to consider the scope of it. Should that method really be accessible for everyone? Should that variable be exposed to only my class or to everyone?

When a variable or method is declared as private, other objects won’t be able to set/retrieve those variables or call on those methods of your class. In fact, they won’t even know about them.

Only the code that you write within the source file can use the private variables and private methods. Other classes won’t be able to.

When would you want to use private?
For methods and variables that aren’t anyone else’s business, you can use the private keyword to limit the access to them. This eliminates some guess-work when it comes to debugging your application and trying to see why some variables don’t have values that you expect them to have because you can rule out the possibility of other objects changing the value. If it’s a private variable, you know that it can only be changed by the code in that same class.

No one is stopping you from making everything public but it’s a good practice to limit the scope of your variables and methods if they don’t need to be public.

Now what kind of iPhone app development tutorial would this be without examples? Let’s jump right into some Objective-C code implementing the stuff we talked about earlier in the article!

7. Defining A Class In Objective-C

Let’s re-use our Superhero example.

When we create a new class, we have the header file (.h) and source file (.m).

The header file in Objective-C
Here’s what our header file will look like:
Superhero.h

A Comment About Comments: 

The green text that’s specified with “//” is a comment. Comments are just statements for the developer to leave remarks for himself or other people reading their code. It won’t affect anything.
Anything after “//” is considered a comment.
If you’ve got a large block of text you want to mark as comment, you can wrap it with “/*” and “*/”. Anything between those two tags will be considered a comment.

In our header file, there’s an import statement and that’s basically to let this Superhero class know about other classes and their respective header file.

Remember, a header file tells other classes what variables, methods and properties are available with your class. So if your class wants to refer to stuff in another class, you have to import their header file.

In this case, we’re importing the Header file of some core Apple classes.

Next, you also notice something beside the name of our class. What is this “: NSObject”?

This is another object oriented programming concept called Inheritance.

8. About Class Inheritance

Not in the sense of money, but in every other sense, Superhero is going to “inherit” all the methods, properties and variables of a class called “NSObject”.

For example, if I was going to create a Spiderman class and I noticed that my Spiderman and Ironman class had a lot of methods or properties in common, I could create a Superhero class that had the commonalities, and then get both my Spiderman and Ironman classes to inherit from the Superhero class.

This is good because I won’t have to write duplicate code and in both my Spiderman and Ironman class and now if I wanted to change something in that common method or property, I only have to change it in one place (in the Superhero class) rather then in two places.

Superhero Tip: Always try to reuse code wherever you can!

Anyways, we got a little side tracked! But that was a really important concept to understand.

Onto the source file!

The source file in Objective-C
Here’s what our Implementation file will look like:
Superhero.m

By default, your source file will have an import statement for your header file or else it wouldn’t know what variables, properties or methods to implement!

9. How To Declare And Use Variables In Objective-C

We have to give Superhero some stats right? Let’s declare some variables in our Superhero class to keep track of them.

Superhero.h

In the code above, we’ve defined several integers to keep track of vital statistics (lines 5-8).
We’ve defined a boolean variable to keep track if our Superhero currently has lasers or not.
And finally we’ve declared an NSString variable to track a piece of text that we’ll use as our Superhero’s greeting message later.

Remember what we talked about earlier regarding scope. These variables are private because they’re declared within the curly braces underneath line 3 and we want them that way. If we want to expose something that another class would be able to set and retrieve, we use properties.

Why did we put an underscore in front of all of our variable names? This is a common naming convention to easily distinguish variables that are private. A naming convention is a system or standard that you follow to name all of your variables, methods and properties so that they are consistently named and the code throughout your app is nice, neat and orderly.

Programmers like things neat and orderly. It’s logical!

10. Declaring And Using Properties In Objective-C

If we wanted to declare a property for our class so that other classes could access it, we would declare it in the header file like this:

Superhero.h

Notice in line 13, we’ve declared a property. There are a couple of key things to note here.

First of all, we’re always going to start with “@property”.

Next, we have two keywords “nonatomic” and “strong”. Let’s talk about “nonatomic” first.

In order to understand what nonatomic means, you have to understand that when we’re writing code we can specify some commands to run in another thread. Thus, you can have parts of your code running and executing in parallel! At some point, those other threads that you sent off to do some work will return to the main thread.

Now imagine if multiple threads are trying to set and retrieve the property of an object simultaneously. This can lead to unexpected behaviour and most likely app crashes!

By default, your property will be “atomic”. What this means is that there will be some overhead added to your code to implement an object-level lock which will prevent that from happening. Imagine that your property is a nightclub and there’s a bouncer in front of your property, ensuring that each thread waits in line to set the property! This is what programmers call “thread-safe”.

So alternatively, if we specify “nonatomic” for our property, that means we’re saying that we don’t need the extra overhead to make our property thread-safe. Maybe because we don’t anticipate multiple threads setting it at the same time, or maybe we’re not using multi-threading in our code.

Ok, so now, what about “strong”? Again, i’ll have to defer to the section on Memory further below!

Next up, we have the property Type. Same thing as specifying a variable type; we want to tell others what type of values this property can have.

And the last part is giving a name to the property. This will be the name that other classes will access the property by.

How would you access or set a property of an object in Objective-C?
Let’s say you had a variable called mySuperhero of type Superhero, that was keeping track of a Superhero object.
You could set the value of a property like this:

This would put the value 9 into that objects stamina property.

And to access that value, you would just say write something like this:

This would assign the value 9 to the variable stamina.

11. How To Declare And Use Methods In Objective-C

And now we arrive at how to declare methods.

Remember that declaring a method involves specifying a method name, the types of variables it expects as input the variable type that it is expected to output and a scope for the method.

Let’s say we wanted to declare a method for our Superhero named “Fight” with the intention of attacking our super villains.

We would declare it in the Header file like this:

Superhero.h

On line 15, we’re declaring the Fight method. Let’s break this down.

The dash “-” (yes even the dash means something!) signifies that this is an instance method. This means that you can call this method on an instance of this class. It relates to a specific instance of an object of this class type. This it the scope of the method.

The alternative is a “+” which means that this is a “Static” method. We don’t need to know about that now, so let’s move on to the next part.

The “(int)” part is the return type of the method. What’s inside the brackets tells us what type of value we can expect to be returned. In this case, it’s “int” meaning that we’ll expect an int value to be returned as the result of this method. This is the return type of the method

The return value could also be “void”. As in, there is no expected value to be returned. This method will take some input and perform some action but will not return any value. However, don’t try to use the keyword, “void”, as a variable type, because you can’t. It doesn’t make sense!

The following part is the method name, “Fight”. Other classes will call this method by this name.

If our method didn’t accept any parameters, that would be it. However, in our example, we have a colon “:” followed by “(int)enemyStamina”. The colon is always followed by a parameter and in our example, the method expects a single parameter as input and it should be of type int. The parameter name, “enemyStamina”, should give some indication as to what that parameter represents; in this case, the enemy’s health! These are the parameter(s) of the method. (Note: Later on in Part 2, you’ll see how to declare a method with multiple parameters).

Finally, the semi-colon at the end of the line tells us that is the end of that statement.

Together, all these elements form the method signature.

We’re not done yet! So far, we’ve defined the method in the Header file but we’ve still got to implement the method in the Implementation file. That is, write the code for the method to actually do what it’s suppose to do!

In Superhero.m, it’ll look like this:

In the Implementation file, you’ll notice that the method signature looks exactly the same as it does in the header file however, there is a block of code inside curly braces right below it. This is where we write the code for this method.

We’ve got two lines of code. On line 7, we’re declaring a new variable of type int called “resultingStamina” and we’re also assigning a value to it. We’re assigning the value of the int parameter that is passed in, minus five. So if the enemyStamina that is passed in has a value of 9, the resultingStamina variable will contain 4.

In line 9, we “return” the variable resultingStamina as the resulting output for the method. Notice that the variable type of the variable we’re returning matches the return type of the method we specified in the Header file! The return keyword is reserved for specifying or “returning” the expected method output.

How would you call the method on a Superhero object? Well, let’s say you had a variable called otherSuperhero of type Superhero, that was keeping track of an Superhero object.

You would call the Fight method like this:

Whoa, there are so many things happening in this statement! First of all, we’re calling the Fight method of otherSuperhero.

Secondly, the Fight method needs an input of int value type remember? So we’re passing in the value in the stamina property of another Superhero object called mySuperhero.

Finally, we’re taking the result of the Fight method and assigning it to the variable resultingHealth.

What would the value of resultingHealth be?

If you remember above in the property section, we set mySuperhero.Stamina = 9, right?

So since the Fight method takes that value and subtracts 5 from it, the value in resultingHealth will be 4.

12. Instances, References And Memory (not the kids card game!)

I’m not referring to that old card game you used to play as a kid where you have all of the cards face down and you try to flip over two of the same card. I’m talking about computer memory!

Your iPhone only has a limited amount of memory. Every object you create will use up some of that memory and when you’re done with that object, it gets destroyed and the memory it took up gets freed to be used for something else.

To make things even more complicated, there are two types of memory, Stack and Heap. The stack is for value type variables and the heap is for reference type objects.

To give you a visual representation of the stack, imagine it like a stack of books. When you allocate memory, you put a book on top of the stack. If you wanted to free memory, you would take the top book off first. This is called LIFO, or last-in-first-out. The last one in, is the first one out like in our stack of books analogy.

With a heap, think of it like a row of mailboxes, each box having its own address. When we allocate memory on the Heap, a mailbox gets picked and the actual object resides in the mailbox.


So this brings us back to the notion of instances of our class. Remember, our class is just a mould or blueprint that we use to create instances of objects of that class. And it’s the actual objects that will interact with each other.

Here’s what a statement to allocate an object looks like:

Let’s talk about the statement as a whole. That statement is creating an instance of the Superhero class by allocating memory for it on the Heap, then calling the method “init” on it and finally the variable *instanceOfSuperhero is being assigned the address of the allocated object.

Did you get that?

When we call alloc on our classname, it returns an instance of that class and then we call the init method on it which initializes the class and returns the same object. The init method is where we can set default values for variables and do anything else we need to get the object ready for use.

Because objects are always allocated on the Heap which is addressed based, whenever we declare a variable to keep track of it, the variable doesn’t actually store the object. The variable is actually a pointer to the memory location of the object (or the mailbox in our analogy before). We denote this by adding the asterisk (*) in front of the variable name.

Any variable that refers to an object holds the memory location of the object, and NOT the object itself. If multiple variables are keeping track of an object, each of those variables is basically holding an address to that object.

Reference counting
Because there’s a limited amount of memory available to your application, if you allocate and create too many new instances of objects, you could hit that limit (bad things will happen to your app. iOS will probably close it!).

It’s important that we dispose of the objects we no longer need or use and free up the memory for other uses. The good thing is that you don’t have to manually do this. In iOS 5.0+, this is handled by ARC (automatic reference counting).

So how do we know when an object is no longer needed?

This is where reference counting comes into play. Each object has a count of references to it. The idea is that if there are no variables referring to it, chances are it won’t be used anymore. If a variable is keeping track of an object, then there’s a chance that it could be used.


Remember when we declared our property earlier on? I told you that I’d explain what “strong” meant. Basically, “strong” means that if the property referencing an object, it will increase the reference count of that object. The alternative to “strong” is “weak”.

If you specify “weak” when you declare your property, it doesn’t increase the reference count of the object so there may be a chance that the object becomes deallocated and the memory is freed, even if you still have a reference to it via your property. Later in the series, we’ll realize when we use “weak”, but usually we will want a “strong” reference to the object.

Let’s Summarize

If you’ve gotten this far into the post then you deserve a huge pat on the back! That was a lot to absorb and we introduced many programming concepts but you’re well underway in your journey to build iPhone and iPad apps!

Below is a recap the main concepts we went through. See if you can recall the main points of each topic as you move down the list. If anything is fuzzy in your memory, I recommend you to give this article another read! On the other hand, if you breezed past this material and want to go deeper into understanding these topics, you can visit the Apple Objective-C Primer.

-Classes and class inheritance
-Variables and variable types
-Methods
-Properties
-Public vs private
-How to define a class in Objective-C
-How to declare and use variables, methods and properties in Objective-C
-Memory allocation and reference counting

What’s next?

In the next part of this series, you’ll dive right into code! We’ll talk about control structures and data structures.

Go To Part 2

Let’s improve this article together! 

I want to make this series and this article in particular the best and easiest to understand resource for beginners to learn how to develop iPhone apps. If you’ve got any feedback, good or bad, please let me know via the comments below so I can update parts which are confusing, add more examples and to continue updating this resource.

And if you’ve enjoyed this article or you know someone who might be interested in learning how to build iOS apps, please share this series with them. It’s targeted at the non-programmer (sort of like an iPhone application development for dummies book) so anyone you know will be able to pick this up and progress towards developing iPhone apps!

174 thoughts on “How To Make iPhone Apps – Object Oriented Programming and Classes”

  1. hi, thanks for this tutorial. It’s helped me gain more understanding on the concept of app programming works. Just one point of constructive criticism if I may. One thing I would like is to have seen though is a working example of this app at the start though as I can relate more to reverse engineering when first learning something. If I see what it does I understand more of the coding functions and how they may interact. As a first timer to app programming I would relate more to seeing the app first then having references back to how parts of the app work If that makes sense. I’ve not read any more tutorials yet so you may have this covered in other sections but its just my first impression. Thanks again. D.

    • Hey Darren, I never thought of that. Thank you for the suggestion! I’ve made a note to incorporate it into the series after I release my course. Thanks!

  2. EXCELLENT refresher! Thank you, just getting back into it all of OBj-c after lots of javascript work stuff. Next up is iOS 7 and UIDynamics.
    At this line “The following part is the method name, “Fight”. Other classes will call this method by this name.”
    You forgot to explain the :
    I know how it works but just noticed the omission

  3. Great job Chris, i really enjoyed this. i am begginer and there is a lot to take in but i can see progress. I feel like pehaps a diagram would do a great job in explaining this faster. Thanks a lot.

  4. Great job, Chris! I’m a Java programmer hoping to add Objective C to my skill set, and this was a GREAT way to gain an understanding of how Java concepts map to Objective C syntax.

    One small thing, though, and I wish I had a way to send this feedback privately. There are a number of grammatical goofs that kept distracting me from the content. Mostly it was using the wrong “its” (it’s is “it is,” not the possessive; if something belongs to “it,” then that thing is “its”), though you also butchered “begs the question.” Most people do, and it is a bete noire of mine!

    • Hello Boots, THANK YOU!

      That was awesome. I had to look up the proper use of “begs the question” and it’s versus its but I’m glad I did and I’m glad you pointed it out!
      I fixed the errors in this article relating to those two goofs and it’s going to be something I’ll remember for all of the writing I do in the future.
      I don’t have the capacity to go through all the old articles right now but again, your feedback was much appreciated! Thanks!

  5. Hi Chris,

    Awesome advice and instruction for newbies like myself. However, I have a problem getting the map to load. Here is the message from the Log Navigator, pointing to my viewDidAppear method:

    “Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UIView setRegion:animated:]: unrecognized selector sent to instance 0x9a95da0′”

    I wonder what I did wrong?

    • Hey Loren,

      From the code above, the thing that is wrong is that you’re trying to call the “setRegion” method on the UIView. Instead, you should call that method on the MapView object.
      In the tutorial, i’ve got a property referencing the MapView so i can write “[self.mapView setRegion…]”

      Hope that helps!
      Chris

  6. Chris
    It is very obvious that you dedicated a lot of time constructing these, and I would like to thank you for your time. It is in a very easy to read, and understand format. Great job, and thanks again.

  7. I don’t know how I was randomly lead to this article, but I am so grateful I am looking forward to religiously follow these and work my way to app development , its the language of the future !

  8. Hi Chris,

    I can see a LOT of appreciation here for your hard work but I still thought it necessary to scroll and give you props.

    I have looked at codeacademy, learningcodethehardway, a lot of the links on the first page of google search for “programming ios apps” and even considered purchasing a treehouse subscription. I’m glad I stumbled upon this, you have a refreshing take on introductions to programming and you have done a great job of explaining things with clarity and appropriate examples.

    I am looking forward to Parts 2 to 5 and urge you to continue with this because you have a knack for teaching my friend.

    Most appreciative and, well wishes from Australia mate

    • Hello Chuck, I can’t express how much I appreciate your message! I never thought that this many people would be reading and I’m glad that you guys are learning from my tutorials. Reading these messages really is the best part of the day! 🙂

  9. thanks…i really enjoyed reading this…looking forward to exploring the world of programming! Thanks for taking the time!

  10. Hi Chris,

    The link to Objective-C Primer on Apple’s dev site appears to be broken — http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/ results in a Page not found.

    There appears to be a primer on the Mac Developer site at https://developer.apple.com/library/mac/referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/ .. maybe they’ve renamed the one for iOS :S

    Maybe the following is relevant?

    https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html

  11. I’m only 12 and I understood most of that mainly because of the simple terms and analogies like the superhero or the letterboxes. I just had one question though, when you use all the symbols and new lines in the coding examples if you didn’t specify a need for them were they still important or were they just to keep it neat and clear?

    • Hello! Thanks for taking the time to comment and read the material! The new lines are just to keep it neat and clear but the symbols are necessary. They’re part of the objective-c language. They’ll probably seem really foreign right now but over time you’ll understand which brackets you need to use. I’ve gotten this question (about the symbols) quite a bit, so I’ll create a cheatsheet or something for the symbols. Thanks again!

  12. Hi Chris,

    Excellent overview! I didn’t “get it” all, but I’m 47 and never programmed further than HTML. I’ll re-read a couple times to see if I can get it. I’ve never seen coding explained in such an easy way before. I appreciate it a lot. Will show my appreciation as I continue through the course with a donation. Just not sure if it will be worth anything to me yet, as I may not continue and just decide to pay someone to do my iPhone apps.

    Looking forward to grasping all this and moving on to your video series I saw on Youtube. I hope this is all worth your while.

    Cheers,

    Vern

    • Hey Vern, I really appreciate the time you took to comment and thank you for the generosity! I love that you’re giving it a shot to learn yourself. Also, I would recommend to click the “Start here” link at the top and go through those videos as it’s my 2nd attempt at teaching a beginner’s course and i believe that it’s much easier to understand!

      Thanks
      Chris

  13. I have what I think is a great idea for an app… Please call me thick but i’m really lost here.. I have no experience at all in this field and reading this just confused me to the max….

    • Hey Daz, I’m glad you commented or else I wouldn’t have been able to help you!
      I just wanted to make sure, have you tried the Basics series first? Those lessons are better suited for a beginner. You can access them via the “Start Here” link at the top of the page.
      Please let me know what you think of those!
      Chris

  14. I have 1 suggestion for your series. Can you specify what kind of hardware/software that we need to make iphone apps? I’m excited to make them, but I’m afraid that I cannot with a Windows 7 OS.
    Otherwise, thanks for this article Chris! It’s really informative, and now I’m pumped to make apps.

    • Hey Wayne, thanks for the suggestion! I’ve mentioned what hardware/software is needed in the “Tools” section above, but you’re right, i should include it here! Unfortunately, you’ll need a mac 🙁 There are people who’ve gotten hackintoshs running on PC, but it seems to be a hit or miss..

  15. hei man good work, really good article but section 11 and 12 is still too complicated I missed many points from section 11 middle to the rest. If you could possibly edit section 11 and 12 it would be more than fantastic!

  16. This is so helpful! Just one suggestion, I’m sorry if you already did this and i didn’t notice but could you make a sort of key showing all the symbols and the meanings that we can print because all the * and – are confusing and I’m not sure what they mean, thanks for the help!

  17. Hi Chris,

    Nice tutorial and easy to understand from basics.
    One small question, what is the implication of square brackets in
    Superhero *instanceOfSuperhero = [[Superhero alloc] init]?

    • Hey Ranajit, that line is creating a new Superhero object and then assigning it to a variable called “instanceOfSuperhero”.
      To get to details, the square brackets is for calling methods. In the line above, “[Superhero alloc]” is calling the alloc class method of the Superhero class and this will return a new Superhero object. Then the outside brackets is for calling the “init” method on the returned object from “[Superhero alloc]”.

      Hope that helps!

  18. Hello, im think its great way you are doing this but this is to hard to understand for me without and illustrations. so i would recommend you to make some powerpoint pictures to theese articles to make it more understandable for people that are not used to thinking this way about things. i guess. but your youtube tutorials are great. 🙂

    • Thanks for the feedback Sigvart! I’m making a conscious effort to use more diagrams and screenshots. Please check out the new Basics series (Click “Start Here” at the top of the site). Would love any feedback you have on the new lessons! Thanks, Chris

  19. Holy Cow this is going to take some time to figure out.. Can I pay you to write an app for me? Or you can be part owner if you’re interested;) It’s probably worth a trillion dollars lol.

  20. Thanks Chris for making these tutorials. They are very different from the other tutorials out there – I am finally understanding how it works instead of just following someone’s “do this, do that” list.
    Keep up the great work!!!

    • Thank you Loralea, that’s exactly what I’m trying to do: explain so that people understand rather than just pointing out what to do.
      Thank you so much!

  21. Hi Chris, thanks for helping us out on learning to code with Objective-C. At first I subscribed to the Stanford classes but that was just too overwhelming seeing that I have never did coding before. I need to develop an App for my desertion and learning from you will make the journey in building this App just so much easier. I will need some assistance in a later stage and was wondering if it is possible to ask you a few questions then. Keep up the great work you doing. 😉 regards, Franco

    • Hello Franco,

      I’m glad that my material can help people and congrats on taking this journey to learn programming. It’s fun!
      Please send me any questions you may have!

      Chris

  22. Hey Chris,

    Man you are awesome, I just jumped from finishing 5 videos of Xcode from your youtube channel as you said if I’m new i should read these first, I always had this issue i never understood these basics of Objective-c and everywhere else they just keep teaching you like you know these basics, this time I’m really enjoying and not going to quit again, we all advantage takers must donate Chris for this effort, so that keeps him motivated, the time Ill learn something Ill send you gift straight from Pakistan (Thats my Country), now you are my first GURU about programming.

    Best Regards
    Junaid Kureshi

  23. Just to note, if you are, like me, still operating on Mac OSX 10.6.8 and want to use xCode 4.0.2 or newer, you have to upgrade to 10.7 or better, which then means that your older software, like my Photoshop CS3, may no longer work. Instead, you’re stuck with xCode 3.2.6 if you don’t want to pay Apple $99 developer fee. This is why I will likely stick with HTML5 and JqueryMobile for now.

  24. Hi Chris,

    I am a newbie in all aspects of programming and developing application. I hope, if you are not so busy, you can reply to my messages in the future. I have not even began to read the posts but I have this feeling that I am definitely going to learn many things.

    Thank you

    Regards,

    Joe

  25. i am only 16 and trying to learn coding but i have such a hard time understanding this :3 but i wont stop i will just read it a couple times more

    • Hello!

      Please feel free to contact me in the orange box on the right-hand side if you have questions!

      Thanks for reading!
      Chris

  26. Hello, when I go to my source file and type #import “Superhero.h” the source file is unable to find the Superhero file from the header. I typed in everything exactly as you had it and even checked my spelling, still not working! Can anyone help me with this?

    • Hey Paul, you can contact me through the orange box in the right-hand side bar of the site and show me your xcode project. I’ll see what’s going on.

  27. Hey Chris , thanks for sharing your knowledge

    my feedback : consider iam reading this at 5 am without sleeping , it may be the reason or not but i find the superman and ironman a bit confusing , i know you choosed that to make it easy for us but for me its still confusing , another thing is examples and illustartions with details and for each word of the programming jargon with a color or explantation near it to make really clear .

    i repeat thank you so much

    • Hey Ahmed, thank you for this feedback! I agree.. i was using the superhero metaphors but i think i abandoned it half-way. I’ll get around to revising it! Thanks again

  28. Hey Chris,

    This is what im talking about, Your lessons is easy to understand to me compared to a lot of other tutorials on the web thanks a lot man, I’m getting this, and it’s exciting.

  29. Chris,
    I can’t thank you enough for the willingness and time you took to put all of this together. Your site and videos have been an amazing source of information. Learning from you has been a blessing. Keep it up!

  30. Hey Chris,

    Accidentally stumbled upon your site and really excited that I did. Started with this first post as I’m far from being a programmer. I have a question for you, I’m having trouble grasping some of the above and you’ve done a really good job in writing it out, is there anything I can do to absorb it better? It’s around the Methods that I begin to lose my grip, will it eventually make sense if I read the next few posts or should I completely understand this before moving on?

    Regardless, thanks for writing such an awesome introduction to coding for iPhone.

    Pat

  31. Even though I knew OOPS I thought to explore how do u explain things?
    You really have a knack for explaining things.

    Keep it up.

  32. Great article for beginners. I have exp in Java/ J2EE / Flex and other technologies. I wanted to learn iOS development. I am referring your videos and articles.. Awesome work.

  33. Chris,
    I have read and been exposed to several tutorials, videos and concepts. I have built a few apps with basic ‘see-n-says.’ Your information allows me to understand what I am doing. This helps to create a solid foundation.

    Thank You!

  34. Chris,

    Thanks for what you are doing.. That’s a lot of work you put into something so great for others. I am completely new to this but very interested. Will have to go through. Articles many more times but look forward to getting there. Thanks again

  35. I have a very limited knowledge in Java and C++ and have been hoping to get in to Obj-C. Thanks for this! Very straightforward and concise!

  36. Hey Chris..just started to dive into programming with no experience..cant wait to really dive in and get into your videos..you seem to be a great teacher so far..any tips for beginners? do you happen to have this info in a .pdf format..thanks alot Michael

  37. Good stuff for my mind in this inspiring article! Really, it was a lot to absorb and I absorbed it with appetite. I like the analogy regarding stack and heap.
    Thanks a lot, Chris!

  38. Hi Chris,

    Awesome article! Your analogies make things so much easier to understand. I’m a bit confused on where the asterisk goes (i.e. after NSString, or before the NSString variable name, or when to do which), but maybe I just need to do some more tinkering and reading. Thanks!

    • Hey Bernice! Thanks for reading!
      When you’re declaring variables, it’ll be NSString *variablename.
      When you’re specifying method parameters or return type, it’ll be (NSString *).
      Such as:
      (NSString *)methodname:(NSString *)param1;

      Thanks for reading 🙂

  39. Chris,

    Your tutorial is awesome. Its pretty fun and easy to understand. Please continue. Looking forward for more demos. Thank you.

    • Hello Reshma, thanks for the kind words! I’ll be finishing the last post in this series in the upcoming week so please subscribe and stay tuned!

  40. Hi Chris,

    I really like what you did here. Great job, keep it up!

    Just one thing, you declare _stamina as a private variable and Name as a property, but later in you example you use property stamina. I found that little confusing.

    Looking forward to the rest of the series.

    • Hello 5o,

      Thank you so much for your feedback! I’ve made this correction and you’ve just made it more clear for everyone reading after you! 🙂

Leave a Comment

Share
Tweet
Pin