Objective C is a programming language, which is sleeted by Apple for developing the application for iPhone and Mac systems.
Objective C is a programming language, which is sleeted
by Apple for developing the application for iPhone and Mac systems. Here we are
providing easy to learn Objective C tutorials. We will be explaining the
programming language with easy to learn examples. You will find these Objective
C tutorials very useful in gaining the core concepts easily and in very less
So, let's get started with Objective C.
Objective C Tutorial
About the Objective C tutorial presented here. In this complete guide of
Objective C you will be learning the programming concepts by doing the
coding. We follow the learn by doing concepts.
This section provides you the basic introduction about Objective C
programming language. Objective C is very old programming language and it
was designed and developed in 1980. Now Objective C has become popular once
again as it is being used by Apple to developing applications for Mac system
- Why Objective C?
In this section we will learn about the importance of Objective C and "Why
Objective C?" is used as programming language to develop
applications for Mac System and iPhone.
C Hello World Example
In this section I will show you how to develop Objective C Hello World
- Objective C
In this section you will learn how to use Objective C on Windows machine. We
will download and install Objective C Windows compiler. On windows GNU C
compiler can be used to compile the Objective C program.
- Objective C on
I this section we will show you how to compile and run Objective C program
on Mac machine.
In this section we will show you how to compile Objective C program on
windows and Max OS x machine. Compiling Objective C program is necessary as
it generates the executable program that can run.
- Objective-C keywords
In this section we will know
about the keywords used in objective-C language.
Objective-C is a superset of C language, so program written in c and C++ should
compile as objective-c.
- Message Expressions and comments
Like C and C++ objective-C provides comments.
Programmer can use single or multi line comments in the code according to the
Message expressions are enclosed in square brackets.
- Class and Method declaration and definitions
Because of objective-C is the extension of ANSI-C and it follows an object
oriented approach so provides classes and objects. The way to declare and define
classes and creation of object is little bit different from C and C++.
- Objective-C program with multiple parameter
Objective-C enables programmer to use method with multiple parameter. These
parameter can be of same type or of different type.
This is a sample program that shows sum of three numbers as output.
Objective-C enables user to define constructor with the help of self and super
keywords. Like java Objective-C has parent class and programmer can access its
constructor by statement [super init], this statement returns a instance
of parent class which we assign to the 'self' keyword, actually 'self' plays
same role as this keyword in C++ and Java.
Access Modifiers and Garbage Collection
Previously it was a requirement to allocate and release memory manually to
assist with this problem it provides a reference-counting memory management
system through retain and release keywords.
- Class level
Objective-C provides facility of class level
access. In the examples given above we have used '-' sign before method, '-'
means instance level access. Now we will see how to define method that can be
access on class level.
- Exception handling in Objective-C
Objective-C provide exception handling to handle exceptional conditions so that
code can be easier to write, easy to detect exceptions in the code and easier to
maintain as well. To take support of exception handling make sure the -fobj-exceptions
flag is turned on.
- Objective-C Inheritance
Objective-C enables programmer to inherit common methods and properties from
other class, known as inheritance. Class from methods and properties are
inherited known as Base Class and class that inherits known as Derived Class.
Dynamic Types in Objective-C
Objective-C provides many methods to work with
dynamic types. With these methods programmer can check that object is of the
given class or not, given method is member of the given class or not etc.
- Objective-c memory management: retain and release
Objective-C uses two methods retain and release. In Objective-C each object has
an internal counter that is used to keep track of all references used by the
objects or object has.
- Objective-c Dealloc
When an object contains another objects so before deallocation programmer
needs to release all those objects. This example shows how to use method dealloc,
when you want to deallocate an object that has already some other objects
When programmer wants to add some more
functionality to the class, typically extend the class. But this is not a right
way everywhere, so like ruby Objective-C also provides categories to achieve
Posing is similar to category but it works a little bit different with the
category. It enable programmers to pose subclass to super class globally. When
subclass posed on super class method which are same in both classes are override
with the subclass methods.