36
iPhone Development JaxCodeCamp 2009

iPhone Development

  • Upload
    melora

  • View
    16

  • Download
    0

Embed Size (px)

DESCRIPTION

iPhone Development. JaxCodeCamp 2009. Who am I. David Fekke .NET Developer, ColdFusion Work at LPS Presenter JaxDug, JaxJug, JSUG & JaxFusion Mac User 1986. Alan Kay. Smalltalk is object-oriented, but it should have been message oriented. Alan Kay. - PowerPoint PPT Presentation

Citation preview

Page 1: iPhone Development

iPhone Development

JaxCodeCamp 2009

Page 2: iPhone Development

Who am I

•David Fekke

•.NET Developer, ColdFusion

•Work at LPS

•Presenter JaxDug, JaxJug, JSUG & JaxFusion

•Mac User 1986

Page 3: iPhone Development

Alan KaySmalltalk is object-oriented, but it should have been message oriented.

Page 4: iPhone Development

Alan Kay When I invented the term

Object-Oriented, and I can tell you I did not have C++ in mind.

Page 5: iPhone Development

Bjarne StroustrupC makes it easy to shoot yourself in the foot; C++ makes it harder, but when

you do, it blows away your whole leg.

Page 6: iPhone Development

The Apple Way

Page 7: iPhone Development

Assumptions

•Somewhat familiar with OO concepts

•Used a language like Java, C# or C++

•Open minded

•Actually used an iPhone or iPod Touch

Page 8: iPhone Development

Requirements

•You need a Intel Mac with OX 10.5

•Some knowledge of OO concepts

•Xcode tools (FREE)

•iPhone (SDK)

Page 9: iPhone Development

Developer Programs

•iPhone Individual ($99)

•iPhone Enterprise ($399)

•iPhone Student

Page 10: iPhone Development

App Store

•Submit Apps with Individual program

•Apple keeps 30%, you keep 70%

•Refunds: you pay 100%

Page 11: iPhone Development

iPhone Platform

•ARM Processor

•128/256 MB RAM

•BSD UNIX

•Mach Microkernel

•COCOA APIs

Page 12: iPhone Development

COCOA

•COCOA is a OO Framework

•Based on NextStep

•Mostly written in Objective-C

•iPhone uses COCOA Touch

Page 13: iPhone Development

COCOA Framework•NS (NextStep)

•CF (Core Foundation)

•CA (Core Animation)

•CI (Core Image)

•Core Data

•OpenGL

Page 14: iPhone Development

COCOA Conventions

•Most classes begin with NS, I.E. NSObject, NSString, NSArray or NSNumber

•Designed around MVC pattern

•Heavy use of delegation

•iPhone specific components based on UIKit

Page 15: iPhone Development

COCOA Touch APIs

•Accelerometer

•Location API

•Multi-Touch

•Camera/Video Input

•Map Interface

•OpenGL ES

Page 16: iPhone Development

Objective-C

•Somewhere in-between C++ and Java

•Invented in 1980’s for Next Computing

•Based on C with SmallTalk like extentions

•Used in COCOA, OpenStep and GNUStep

•Class based OO language

Page 17: iPhone Development

-(BOOL)validateNumRangeWithStartNumber:(int)startNumber EndNum:(int) endNumber{

if (startNumber >= endNumber){

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"End value Too Small" message:@"Sorry" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

[alertView show];[alertView release]; return YES;

} else {return NO;

}}

Page 18: iPhone Development

Obj-C vs C#

Obj-C C#[[object method]

method];obj.method().method();

Memory Pools Garbage Collection +/- static/instancenil null

(void)methodWithArg:(int)value {}

void method(int value) {}

YES NO true false@protocol interface

Page 19: iPhone Development

Objective-C Structure

•Obj-C Class composed of two files: header and implementation, or .h and .m

•header uses the @interface and implementation uses @implementation

Page 20: iPhone Development

#import <UIKit/UIKit.h>

@interface LottoRandomAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window;}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

Page 21: iPhone Development

#import "LottoRandomAppDelegate.h"

@implementation LottoRandomAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {

// Override point for customization after application launch [window makeKeyAndVisible];}

- (void)dealloc { [window release]; [super dealloc];}

@end

Page 22: iPhone Development

Selectors

•SEL type defines a method signature

•-(void)setAction:(SEL)aSelector

•SEL mySelector;

•mySelector = @selector(drawMyView:);

•[myButton setAction:mySelector];

Page 23: iPhone Development

Memory Management

•C used methods like malloc and free

•Obj-C uses object retain pool

•Garbage Collection on the Mac, but not on the iPhone

•Inherit management methods from NSObject

Page 24: iPhone Development

Memory Management Cont.

NSString *myName = [[NSString alloc] init];

// retain count of 1[myName retain];

// retain count of 2[myName release];

// retain count reduced to 1[myName autorelease];

// object released by pool magically

Page 25: iPhone Development

MVC

•Model-View-Controller

•COCOA has Controller classes

•UIViewController Class

•Views are in the XIB (NIB) files

Page 26: iPhone Development

Controllers

•iPhone Apps commonly have multiple views

•Push and Pop the Controllers for each View

•Navigation Controller used to load different views

•UINavigationController

Page 27: iPhone Development

SDK Tools

•Xcode 3.0 IDE

•Interface Builder (Views)

•Instruments (Profiler tool)

•iPhone Simulator

Page 28: iPhone Development

Xcode 3

•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

Page 29: iPhone Development

Interface Builder

•Tool for laying out interfaces

•Separate Tool from Xcode

•Bind Actions and Outlets in Controllers

Page 30: iPhone Development

Demo

Page 32: iPhone Development

Book Resources

•COCOA Programming For Mac OS X by Aaron Hillegass

•iPhone Developer’s Cookbook by Erica Sadun

•APress Books

Page 33: iPhone Development

Snow Leopard•Mac OS X 10.6 released yesterday

•Optimized for 64bit

•Xcode 3.2

•Static Analysis Code warning and hinting

•OpenCL Library

•Grand Central Dispatch

Page 34: iPhone Development

Mono Touch

•Develop iPhone Apps with C#

•Mono IDE

•Ahead of time compilation

•Works with IB

Page 35: iPhone Development

Contact

[email protected]

•twitter.com/davidfekke

•http://www.fekke.com/blog/

Page 36: iPhone Development

Questions?