iPhone Application
Development
Ankit Gautam(0709113013)
Atul Yadav(0709113020)
Chetan Singh(0709113023)
Chinki Singh(0709113024)
iPhone
Internet and multimedia enabled
smart phones.
Designed and marketed by
Apple Inc.
Launched on Jan 9,2007.
• iPhone models
iPhone(original)
iPhone 3G
iPhone 3GS
iPhone 4
• iPhone 4 released on June 24,2010
• Approx 6.4 million iPhone users in U.S.
iOS
Apple’s mobile operating system.
Derived from Mac OS
Platform Dependent OS
iPhone Application
Written in Objective-C.
Third Party Application.
SDK released on March 6,2008.
iPhone SDK
SDK consists of:
Xcode
Interface Builder
iPhone simulator
Apple App Store
Upload/Download iPhone applications.
Uploading your applications
Developer Registration
Standard Package - $99/year.
Enterprise Package - $299/year.
Downloading an application.
Select application from App Store.
Do Payment to download the application.
Price of application is set by the developer.
70% of price/download - developer
30% of price/download - Apple
iPhone application development – HUGE MARKET
Till Sep 1,2010
No. of application in App Store: 2,50,000
No. of downloads from App Store: 6.5 Billion
XCode
X Code IDE
X code is an IDE for creating
iPhone and Mac Applications.
X code comes with integrated
Cocoa framework ,GNU
compiler,I phone simulator,
Interface Builder.
X code supports development
in languages such as C,C+
+,Objective C,Objective C++.
X Code Features
Source Editor.
Interface Builder.
iPhone Simulator.
Compilers.
Complete Documentation.
Cocoa Framework.
Cocoa Framework
The Cocoa frameworks consist of libraries, APIs, and
runtimes that form the development layer for all of
Mac OS X.
By developing with Cocoa, you will be creating
applications the same way Mac OS X itself is created.
Your application will automatically inherit the great
behaviors and appearances of Mac OS X.
Using Cocoa with the Xcode IDE is simply the best
way to create native Mac applications.
I Phone Simulator
The iPhone Simulator
runs your application in
much the same way as
an actual iPhone device .
It is quick to launch and
debug
It can even simulate
touch gestures by using
the mouse.
Interface Builder
Interface Builder allows
Cocoa developer to create
interface for applications.
The resulting interface is
archieved as a .nib file .
The user interface objects
contain items like text fields,
and pop-up menus ,buttons.
On running an application, the proper NIB objects are
unarchived & connected with the binary of their
owning application .
Interface Builder's palletes that contains user interface
objects are completely extensible.
Performance Analysis Tool
A truly unique application that helps you track the
performance of Mac OS X and iOS applications .
Instruments collects data such as disk, memory, or CPU
usage in real time, either on your Mac or remotely from a
connected iPhone.
The data is graphically displayed as tracks over time,
making it easy to pinpoint problem areas.
X code Distinctive Aspect
While code is written on it,it compiles code in the
background.
With ZERO LINK feature, only the files that are
necessary are linked at build time making linking very
fast.
Apple came up with Fix and Continue that allows you
to find bugs, and fix them, without ever closing the
application .
X code has the ability to distribute (over a network
using bonjour protocol) the current build of your
project to others running X code.
The Documentation Viewer in Xcode allows you to
get vital information on various aspects of Xcode,
Cocoa, Objective c etc.
User Support
Easy to learn.
Flexible.
Familiar interfaces.
Rapid development support.
X code releases
After 1.x,2.x,3.x series, recently X code 4 is released
by Apple in June 2010.
X code 4 contains Interface Builder integrated in it
unlike all other previous releases.
X code 4 has high performance LLVM compiler
integrated in it.
Like LLVM, the new LLDB debugger engine is
designed to consume much less memory, and be a
rocket when it comes to performance.
Objective-C
Introduction
Objective-C is implemented as set of extensions to
the C language.
It's designed to give C a full capability for object-
oriented programming, and to do so in a simple
and straightforward way.
Its additions to C are few and are mostly based on
Smalltalk, one of the first object-oriented
programming languages.
Objective-C 23
Why Objective C
Objective-C incorporates C
You can choose when to do something in an object-
oriented way
Objective-C is a simple language.
Objective-C is the most dynamic of the object-oriented
languages based on C.
Most decisions are made at run time
Objective-C 24
Messages
message expressions are enclosed in square brackets
[receiver message]
The receiver is an object. The message is simply the
name of a method and any arguments that are passed
to it
Objective-C 25
Foundation Framework
The Objective-C Foundation Framework is a
essentially set of classes that are provided to speed and
ease the process of developing applications using
Objective-C.
classes that comprise this framework all begin with
the letters "NS“ (NSString,NSObject,NSDate etc)
#import <Foundation/Foundation.h>
String Constant
@”This Is a String”
NSString
NSLog
Used as a print statement.
Example: NSLog(@”Hello World”);
Calling Methods in Objective-C
Other Languages
[Link]();
• In Objective-C:
[myObject someMethod];
Methods that returns result
Other Languages
result=[Link]();
• In Objective-C:
result= [myObject someMethod];
Methods that takes a argument
Other Languages
[Link](arg);
• In Objective-C:
[ myObject someMethod : arg];
Methods that takes multiple argument
Other Languages
[Link](“Today Only!”,0);
• In Objective-C:
[ title insertString:@”Today Only!” atIndex:0];
Defining a Class
In Objective-C, classes are defined in two parts:
An interface that declares the methods and instance
variables of the class .
An implementation that actually defines the class
(contains the code that implements its methods)
Objective-C 33
The Interface :Student.h
#import <Foundation/Foundation.h>
@interface Student:NSObject{
//iVars
int rollno;
NSString *name;
}
//public methods
-(void) print;
-(void) setRollno : (int ) r;
-(void) setName : (NSString *) n;
@end
Objective-C 34
The Implementation:Student.m
#import<Student.h>
@implementataion Student
-(void) print{
NSLog(@”Roll No:%i ,Name:%@”,rollno,name);
}
-(void) setRollno : (int) r{
rollno=r;
}
-(void) setName: (NSString *n) {
name=n;
}
@end
main.m
#import <Foundation/Foundation.h>
import “Student.h”
int main(int argc, const char *argv[]) {
Student *a=[Student new];
[a setName: @”ATUL” ];
[a setRollno: 20 ];
[a print];
return 0;
}
Declaration
Instance Variables
float width;
float height;
BOOL filled;
NSColor *fillColor;
Methods:
names of methods that can be used by class objects, class
methods, are preceded by a plus sign
+ alloc
methods that instances of a class can use, instance methods, are
marked with a minus sign:
- (void) display;
Objective-C 43
Memory Management
Manage memory for every object you create.
If you own a object,it is your responsibility to release
it.
after the use
[object release]
Sample iPhone
Application
Open Xcode
Select an already made
application or make a new
application
Write code
Make all necessary files &
add all the resources which
will be needed in your
application
Build & Run Application
Application is loaded into iPhone simulator
Home page of Application
View Controller of Main Window is opened
Title view is displayed
View Controller of this view was initialized in previous View Controller
View Description
Alert view pops up on clicking any row of Table view showing
description of that Topic.
Technical Aspects Of This Application
Four Pillars of any View Based Application
xib window
Inspector window
Library window
View window
xib window
Gives description of all the
Outlets and Methods
declared in class.
Associated with a particular
View Controller class.
Inspector Window
Properties of any object can be set or changed
Library window
Objects can be added into view by dragging them from this window
View window
This is the window where objects are displayed
Thank You