With the first successful launch of Apple Store, iOS development became a charm for every software engineer. Developing a small application for iPhone and getting paid for your efforts worths giving a shot. Alot of people having little or more IT background try to learn iOS development and it has become a ever green market for the software engineers as well.
This tutorial about iOS development is written for the people with some basic programming knowledge and its purpose is to teach you how and with which tools you can learn iOS development.
Prerequisites of iOS Development
Before jumping into the world of iOS development you must have knowledge of following things.
I. Object Oriented Programming.
II. Should have some knowledge about the MVC pattern.
III. You must be familiar with terms like
A. Class
B. Instance
C. Message
D. Method
E. Instance Variable
F. Supercalss/Subclass
G. Properties
MVC
MVC is a popular design pattern , an easy way to understand MVC: the model is the data, the view is the window on the screen, and the controller is the glue between the two.
Modal
We can say that Modal is “What” of your app. Your model will be object representing data and application logic.
View
As the name suggest the Views are the visual representation of your application.
Controller
Controller decides how your model is presented to the view.Controller is the link between the Modal and the View and also it has all the UI Logics.
Objective C
Objective C is the programming language used for iOS Development in Xcode.Objective C is strict superset of C.It’s syntax is little bit different from other object oriented languages like C# or Java.
Here is a little sample Code of Objective C.
Code for Person.h
@interface Person : NSObject {
@public
NSString *name;
@private
int age;
}
@property(copy) NSString *name;
@property(readonly) int age;
-(id)initWithAge:(int)age;
@end
And its implementation class would be like this.
@implementation Person
@synthesize name;
-(id)initWithAge:(int)initAge {
self = [super init];
if (self) {
age = initAge; // NOTE: direct instance variable assignment, not
property setter
}
return self;
}
-(int)age {
return age;
}
@end
Xcode
Xcode is the IDE that we use to do iOS development and for using Xcode you must have a mac machine with OS X 10.9 or 10.8 installed in it.Xcode is free to download from Apple App Store .So , to install Xcode just search for Xcode on Mac App Store and than just click install button to install it.The download will be of about 2GB you must have a good internet connection.
Hello World
So , if you have successfully installed Xcode on your Mac than we are ready to make our Hello World app.This app will only have one label which display the text Hello World but this will give you an idea to setup your app.
Step 1: Open Xcode from Finder or Dashboard.After opening Xcode Click on “Create a new Xcode project” for creating your first Hello World App.
Step 2:When you create new Xcode Project you go the option to select the template for your new project.As you can see in the screenshot below you have several options of available in Xcode but for now we will Create “Single View Application”.
Step 3 :After selecting your template for the app you will move to option where you tell Xcode name of your app and its company identifier.This identifier is supposed to be your unique identifier so normally people name it like com.YourCompanyURL/Name. YourName and than in bundle Identifier the name of your app would be added for Xcode.Here if you define any Class Prefix and that Prefix would be added to your ViewController by default but you can change it afterwards if you want.And in last you can see the option of Devices , here you can select iPhone , iPad and to
target both you have to selected Universal.After clinking next Xcode will ask you to define the path of the Path.
Step 4 :Now you are project is ready to develop.As your can see in the screenshot below by default items for oneiew Controller are already added to your project hence the template name Single View Controller.
Step 5 :The interact with the View on your
you can see your View and current it is associated with the Controller file “ViewComtroller”.If you run your app at this point than in the emulator you will only see blank white screen as we have nothing till now.You can run your app by clicking the Play button on the top right corner of the screen.
Step 6:Also try to play around with the UI of the Xcode. Below in the image you can see different sections of Xcode.
Step 7:Now coming back to the HelloWorld app that we had to make.Go to the
Utility area and their you will find different Item which you can drag in your
Storyboard and Views.From their find the Label control as shown in the screenshot
below and from their drag it to your View.
Step 8 : Now in your View you have placed the UI Label. So , change its text double
click on it and it will be ready to be typed inside it , so Type Hello World! here as
showed in the screenshot below.
So , after running your app you will get emulator like shown below.
In this tutorial of iOS Development with Xcode We covered some basic concepts and we Simply made a little Label and wrote our desired text Hello World in it. Lets Move to 2nd Tutorial.