- iPhone SDK: Objective-C Condition
- iPhone SDK Components & Requirements
- Overview of iOS Platform
- Objective-C Tutorial with xCode
- iPhone SDK: Objective-C Creating Custom Class
- iPhone SDK: Using Existing Objective-C Classes
- iPhone SDK: Your First iPhone Application
- iPhone SDK: MVC in iPhone Application Development
- iOS: Working with Actions & Outlets
To develop iPhone Application, you require a MAC & iPhone SDK and it needs to be installed on developing mac machine. iPhone SDK components are as follows.
iPhone SDK Components

Tools: XCode 4
Xcode, one of the iPhone SDK Component, is the development environment we will be working with primarily, which is a free download from Apple’s developer portal. You have to sign up for an iTunes account in order to complete the process. If at any time you would like to test any of your applications on a device, or release them to the public, you will have to pay an annual membership fee of $99. Apple has created a single tool and wrapped all things in that which are required to develop iPhone Application. XCode 4 also provides User Interface Builder, iPhone Simulator which we require to test our application while developing and all this get installed with iPhone SDK installation. we will spend most of our time in XCode.
Language: Objective-C
Objective-C will be automatically installed with iPhone SDK. If you already familiar with JAVA, C++ or C#, they all looks similar to C because they all are C based languages. They share history but they are different from C and different from each other. Look at some code for all those languages:
1 2 3 4 5 |
#include<iostream.h> int main() { cout<<“Hello Boys\n”; } |
1 2 3 4 5 6 7 |
public class Hello { public static void main(String[] args) { System.out.println(“Hello Boys”); } } |
1 2 3 4 5 6 7 |
class Hello { static void main() { System.Console.WriteLine(“Hello Boys”); } } |
All looks different way but they are all consistent. They have their own rules and methods for programming. Objective-C is not like that. Objective-C is C with extra stuff added not changed. If we took some regular C Code and copy in XCode, it would compile just fine. it would be valid Objective-C. Objective-C will installed with iPhone SDK Components.
What confuses many developers that they expect it to be as consistent as say JAVA but it isn’t. There may be 2 ways of doing things:
- Old C Way
- New Objective-C Way
1 2 3 4 5 6 7 8 9 |
#import <Foundation/Foundation.h> int main(int argc, const char *argv[]) { NSAutoreleasePool *pool = [ [ NSAutoreleasePool alloc ] init ]; NSLog(@”Hello Boys”); [pool drain]; return 0; } |
To identify the new code by giving the compiler some clues: This part is Regular C and this part is Objective-C.
Things like using the square brackets which is something that puzzles lots of people when they see this first time but this is Objective-C (above highlighted).
Framework: Cocoa Touch
Cocoa touch is also part of iPhone SDK. Think like this, Objective-C is been developed and then developer thought that what if we have some utility functions in ways of working with say String. So they write a whole bunch of code for string manipulation utilities, wrap in class and call it NSString (NS Coming from NeXT Step). they developed whole bunch of other classes and wrap all hundreds of classes and called that a Foundation Framework. they also build classes for User Interface for iPhone, wrapped up and name it UIKit. and also they developed classes for things to build like Address Book, Game Kit, Message UI, Core Audio, Map Kit, Core Graphics and more and wrapped up with Foundation and UIKit Framework and name it Cocoa Touch.
MVC
To develop iPhone Application using iPhone SDK, you must follow MVC concept. If you are new to MVC then MVC stands for Model-View-Controller – the standard for building modern application. The whole idea behind MVC framework is to build application in a modular way, where we have 3 general parts responsible for creating the output and allowing the interaction with the user. In MVC model is responsible for retrieving data from database or other resources like web services, rss, etc. while view is responsible for how that data will be represented, then what about controller? Controller is glue that links model and view together. Controller uses model to fetch data from database or other resources and populates view with data returned by model. So MVC architecture completely separates database logic, business logic and presentation logic. That’s the main reason of working in MVC architecture.
- Model
Model has the data that is required to render things in the view. So it represents the data that are required for rendering. It also takes over the operation related to the domain. The model is used to do something and get the data.
- View
It takes over the display of the applications state. A view takes care of “rendering the pixels on the screen” and should be as dump as possible. Typically a view class understands one or more model(s) and outputs the information of that model. (A view is not allowed to write in the model.) So the view is aware of the model and knows how to read the data out of it – but never the model should know something about the view!
- Controller:
It glues together Model and View. It controls the user interaction with the model and the view. (It’s a thin layer that connects models with their views)
MVC Architecture normally works this way:
- The request that is sent to a controller. This controller builds a request object and starts the processing of this request.
- That means Controller Objects are called (normally action methods in the controller that belongs the current request. This process is called “dispatching”) and this controllers are responsible to return the correct response. Like normal controllers they do:
- The controller loads/modify model objects
- Pass the model data to a view
- Calls the view for desired output.
- Normally the view that is returned to the browser consists of a hierarchie of subviews and/or widgets.
Pingback: Objective-C Basics with xCode - Code Riddles