iPhone Development

Preview:

DESCRIPTION

iPhone Development. 박종화 suakii@gmail.com. Contents. Requirements iOS SDK iOSOverView Objective-C Design Pattern App Dev Cycle QA. Trend. Smartphone OS. Smartphone OS. Why?. Differences. Only One Running Application Only One Window Limited Access Limited Response Time - PowerPoint PPT Presentation

Citation preview

iPhone Development

박종화suakii@gmail.com

Contents•Requirements•iOS SDK•iOSOverView•Objective-C•Design Pattern•App Dev Cycle•QA

Trend

Smartphone OS

Symbian Research In Motion

Android iOS Microsoft Windows Mobile

Linux Other OSs

CE/ 표준

CE/ 표준

CE/ 표준

CE/ 표준CE/ 표준

CE/ 표준CE/ 표준

CE/ 표준

CE/ 표준 CE/ 표준CE/ 표준

CE/ 표준 CE/ 표준 CE/ 표준

2009 2010

Smartphone OS

Symbian41%

Research In Motion18%

Android17%

iOS14%

Microsoft Windows Mobile

5%Linux2%

Other OSs2%

Why?

Differences•Only One Running Application•Only One Window•Limited Access•Limited Response Time•Limited Screen Size•Limited System Resources•No Garbage Collection

Requirements

Requirements•Intel Based Snow Leopard•iPhone or iPod Touch•Xcode•iOSSDK•Objected Oriented Concepts

Hardware

Hardware

Hardware

Hardware

Software

Developer Programs

•iOS Developer – Individual ($99/year)

•iOS Developer – Enterprise ($299/year)

•iOS Developer – Student ($0)

iPhone Platform•ARM Processor(Samsung, Apple)•512MB RAM (iPhone4)•BSD UNIX•Mach kernel•COCOA APIs

iOS SDK

SDK Tools

•Frameworks•Xcode Tools•iPhone Simulator•iPhone Reference Library

Frameworks•Apple delivers most of its system

interfaces in special packages called frameworks.

•A framework is a directory that contains a dynamic shared library and the resources need to support that library

Frameworks

Xcode Tools

Xcode Interface Builder Instruments

Xcode

Interface Builder

Instruments

Xcode Tools •GCC compiler 4.2•Support for Obj-C, C++, Java,

Python and Ruby (iPhone only uses Obj-C & C++)

•Code editor with code completion•Support for SVN and CVS

Interface Builder

•Tool for laying out interfaces•Separate Tool from Xcode•Bind Actions and Outlets in

Controllers

Simulator

Simulator

Simulator

iOS OverView

iOS 4.1•Multitasking•Folders•Threaded email•iBooks•Game Center•Not support Flash or Java

iOS

Core OSOSX Kernel

Power Management

Mach 3.0 Keychain AccessBSD CertificatesSockets File SystemSecurity Bonjour

Core OS

Core Services

Media

Cocoa Touch

iOS

Core ServicesCollections Core LocationAddress Book Net Services

Networking ThreadingFile Access PreferencesSQLite URL Utilities

Core OS

Core Services

Media

Cocoa Touch

iOS

MediaCore Audio JPEG, PNG, TIFFOpenAL PDFAudio Mixing Quartiz (2D)Audio Recording Core Animation

Video Playback OpenGL ESCore OS

Core Services

Media

Cocoa Touch

iOS

Cocoa TouchMulti-Touch AlertsCore Motion Web ViewView Hierarchy Map KitLocalization Image PickerControls CameraCore OS

Core Services

Media

Cocoa Touch

Application Life Cycle

Event-Handling

Interruptions

Main.m#import <UIKit/UIKit.h>

int main(int argc, char *argv[]){

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];int retVal = UIApplicationMain(argc, argv, nil, nil);[pool release];return retVal;

}

Performance•Do Not Block the Main Thread•Use Memory Efficiently•Floating-Point Math Considerations•Reduce Power Consumption•Tune Your Code• Improve File Access Times•Tune Your Networking Code

Objective-C

OO Terms• Class• Instance• Message• Method• Instance Variable• Inheritance• Superclass/Subclass• Protocol

History

Objective-C•Somewhere in-between C++ and Java•Created by Brad Cox & Tom Love• Invented in 1980’s for Next Computing•Based on C with SmallTalk like extentions•Used in COCOA, OpenStep and GNUStep•Class based OO language

Objective-C• 객체를 중심으로 작성

• 객체는 데이터와 데이터를 조작하는 동작으로 이루어진다 .

• 동작을 객체의 method, 객체의 데이터를 instance variable

• Objective-C 는 동적인 언어로서 실행시에 객체나 매소드가 변할 수 있다 .

Class Interface#import <UIKit/Uikit.h>

@interface HelloWorldViewController : UIViewController {//Instance Variable

UIButton button;UILabel *label;}//property@property (nonautomatic, retain) IBOutletUILabel *label;

//method-(IBAction)sayHello:(id)sender;@end

Class Implementation

#import “HelloWorldViewController.h”

@implementation HelloWorldViewController@synthesize label;

-(IBAction) sayHello:(id) sender {label.text = @”Hello, World”;}

-(void)viewDidLoad {}

- (void)dealloc { [label release];

[super dealloc];}@end

Class Allocation

•HelloWorldViewController *obj = [[HelloWorldViewControlleralloc] init];

Property• 인스턴스 변수에 대한 접근자메소드의 구현의

편리

label - gettersetLabel: - setter

• @synthesize• Dot Syntax

label.text = @”Hello, World”;[label setText:@”Hello, World”];

Properties•Readonly•Retain•Readwrite•Copy•Assign

Calling Methdos[anObjectsomeMethod];[anObjectsomeMethod:

anotherObject];[anObjectsomeMethod:

anotherObjectwithAnotherArgument: yetAnotherObject]

Sending Messages• Objective-C 에서는 해당 객체에 메시지를

보낸다라고 표현한다 .• 객체에 메시지를 보내면 해당 메소드를

불러주는 구조

• Receiver may be nil(null)

Memory Management

•C used methods like malloc and free

•C++ used methods like new and delete

•Objective-C uses retain pool•Garbage Collection on the Mac, but

not on the iPhone

Creating ObjectsNSString *string = [[NSStringalloc] init];

-> You are responsible for releasing the memory

NSString *string = [NSStringstringWithString:@”Hello”];-> The object will be autoreleased.

Reference Counting

•An Object knows how many times it is referenced

•Manually managed or through the autorelease pool

•As soon as it falls to 0, the destructor dealloc is automatically called

alloc-retain-release

alloc+1

retain+1

release-1

release-1

Memory Management

•NSString *name = [[NSStringalloc] init];

•[name retain];•[name release];•[name autorelease];

Obj-C Vs C++

Obj-C vs C++

Obj-C vs C++

Obj-C vs C++

Obj-C vs C++

Obj-C vs C++

Obj-C vs C++

Design Pattern

MVC

View Model

Controller

MVC

•Model•모델은 앱 상태 ( 및 데이터 ) 를

관리하며 , 데이터 영속성을 제공하기도 한다 . 이것은 완전히 UI와는 분리되어 있으며 사용자에게 직접 드러나지 않는 부분이다 .

MVCView•사용자가 실제로 보는 부분이며 ,

사용자에게 모델을 보여준다 . 뷰를 통해서 사용자가 데이터를 변경하도록 하며 이벤트를 생성하게 하거나 이벤트에 응답하도록 한다 . 인터페이스 빌더 또는 프로그램 코드에 의해서 생성할 수 있다 .

MVC•Controller•사용자 입력 때문에 데이터가

변경되거나 데이터가 변경되어 사용자에게 변경된 데이터를 보여주려고 할 때 , 뷰와 모델을 연결 및 중재하는 역할을 한다 . 이 컨트롤러에서 앱의 처리 논리를 구현한다 .

Delegation

•다른 객체를 대신해서 책임지고 어떠한 일을 해주는 클래스

UIAccelerometerDelegate

(the delegator)MainController(the delegate)

Moving

Delegation•Control passed to delegate objects

to perform application specific behavior

•Avoids need to subclass complex objects

•Many UIKit classes use delegates

Target-Action

•Button Touch – Message send

App Dev Cycle

Development Cycle

IdeaCheckDevelopSubmit

Prototype

Create a Mockup http://iphonemockup.lkmc.ch

Prototype

Coding

1 Vs N

Resources

•Images•Sounds•Strings•Database

Test

•DogFooding•Friend•…..

Distribution

Upload

Upload

Questions?

Recommended