Slide 1

Slide 1 text

For Objective-C Web Developers Addam Hardy

Slide 2

Slide 2 text

@addamh this guy Ruby on Rails Javascript Developer iOS

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

web developer? it’s time to evolve

Slide 5

Slide 5 text

tablet sales to surpass desktop sales by 2015

Slide 6

Slide 6 text

demand supply

Slide 7

Slide 7 text

demand supply profit

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

the run down

Slide 10

Slide 10 text

strict superset of C Objective-C

Slide 11

Slide 11 text

strict superset of C compiled language Objective-C

Slide 12

Slide 12 text

strict superset of C compiled language object-oriented Objective-C

Slide 13

Slide 13 text

strict superset of C compiled language object-oriented dynamic Objective-C

Slide 14

Slide 14 text

strict superset of C compiled language object-oriented dynamic strictly typed Objective-C

Slide 15

Slide 15 text

strict superset of C compiled language object-oriented dynamic strictly typed smalltalk style messaging Objective-C

Slide 16

Slide 16 text

strict superset of C compiled language object-oriented dynamic strictly typed smalltalk style messaging very verbose Objective-C

Slide 17

Slide 17 text

difficulties for web developers

Slide 18

Slide 18 text

C bummers

Slide 19

Slide 19 text

C compiling! so much time! bummers

Slide 20

Slide 20 text

C compiling! so much time! the dynamic-ness. sort of. bummers

Slide 21

Slide 21 text

C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading bummers

Slide 22

Slide 22 text

C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading memory management bummers

Slide 23

Slide 23 text

C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading memory management bummers

Slide 24

Slide 24 text

C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading memory management static typing bummers

Slide 25

Slide 25 text

C compiling! so much time! the dynamic-ness. sort of. asynchronous/threading memory management static typing errors bummers

Slide 26

Slide 26 text

xcode

Slide 27

Slide 27 text

xcode

Slide 28

Slide 28 text

xcode

Slide 29

Slide 29 text

xcode

Slide 30

Slide 30 text

xcode

Slide 31

Slide 31 text

xcode

Slide 32

Slide 32 text

xcode

Slide 33

Slide 33 text

xcode

Slide 34

Slide 34 text

typing

Slide 35

Slide 35 text

typing Ruby PHP Objective-C $var = 21; $variable = “This is a string”; var = 21 variable = “This is a string” (int) var = 21; NSString *variable = @“This is a string”;

Slide 36

Slide 36 text

typing C Primitives Common Classes char short long unsigned char unsigned int int float double bool NSString NSNumber NSArray NSDictionary NSMutableArray NSMutableDictionary UIView UIButton id and 20,000 others..

Slide 37

Slide 37 text

header files implementation files wat?

Slide 38

Slide 38 text

headers / implementation class.h The public API for the class @interface Student { NSNumber *age; NSString *name; } @end

Slide 39

Slide 39 text

headers / implementation class.h class.m The public API for the class The instructions for the class @interface Student { NSNumber *age; NSString *name; } @end @implementation Student - (NSString *) name { } @end

Slide 40

Slide 40 text

creating classes

Slide 41

Slide 41 text

classes Ruby PHP class HelloWorld { // instance variables go here // methods go here public function sayHI() { print("Hello World!”); } } class HelloWorld // instance variables go here // methods go here def sayHI puts "Hello World!” end end

Slide 42

Slide 42 text

classes Objective-C @interface HelloWorld { NSString *statement = @”This is a string” } -(void) sayHI; @end

Slide 43

Slide 43 text

classes Ruby PHP class cat extends animal { public function be_cute() { print("I am teh cute”); } } class cat < animal def be_cute puts "I am teh cute” end end

Slide 44

Slide 44 text

classes Objective-C @interface Cat : Animal { } -(void) beCute; @end

Slide 45

Slide 45 text

properties

Slide 46

Slide 46 text

properties @property (nonatomic, retain) NSString *title; @property (nonatomic, assign) int number;

Slide 47

Slide 47 text

properties @synthesize title; @synthesize number; [object setTitle:@”This is my title”]; NSLog(@”%@”, [object title]);

Slide 48

Slide 48 text

object instantiation

Slide 49

Slide 49 text

object instantiation Ruby PHP include_once('HelloWorld.class.php'); $hw = new HelloWorld; $hw->sayHI; require ‘HelloWorld’ hw = HelloWorld.new hw.sayHI

Slide 50

Slide 50 text

Objective-C #import @interface HelloWorld : NSObject { } - (void)sayHI; @end object instantiation header

Slide 51

Slide 51 text

Objective-C #import “HelloWorld.h” @implementation HelloWorld - (void)sayHI { NSLog(@”Hi.”); } @end object instantiation header

Slide 52

Slide 52 text

Objective-C #import #import "HelloWorld.h" int main (int argc, const char * argv[]) { HelloWorld *hw = [[HelloWorld alloc] init]; [hw printHelloDate]; return 0; } object instantiation main.m

Slide 53

Slide 53 text

methods /selectors

Slide 54

Slide 54 text

methods / selectors Ruby PHP function buyItem(item) { $cart = new ShoppingCart; $cart->purchase(item); } def buyItem(item) cart = ShoppingCart.new cart.purchase(item) end

Slide 55

Slide 55 text

Objective-C - (void)buyItem:(ItemObject*)item { ShoppingCart *cart = [[ShoppingCart alloc] init]; [cart purchase:item]; } methods / selectors

Slide 56

Slide 56 text

def addObserver(key_path, options, context) end methods / selectors

Slide 57

Slide 57 text

def addObserver(key_path, options, context) end methods / selectors addObserver(key_path, options, context)

Slide 58

Slide 58 text

-(void) addObserverForKeyPath:(NSIndexPath*)indexPath WithOptions:(NSDictionary*)options AndContext:(void*) { } methods / selectors

Slide 59

Slide 59 text

-(void) addObserverForKeyPath:(NSIndexPath*)indexPath WithOptions:(NSDictionary*)options AndContext:(void*) { } methods / selectors [object addObserverForKeyPath:indexPath WithOptions:options AndContext:nil]

Slide 60

Slide 60 text

common pitfalls

Slide 61

Slide 61 text

common pitfalls NSString *this = @”kitty”; NSString *that = @”kitty”; if(this == that){ NSLog(@”This will not happen”); } if([this isEqualToString:that]){ NSLog(@”This will happen!”); } NO YES

Slide 62

Slide 62 text

common pitfalls @synthesize this; @synthesize that; @synthesize those; @synthesize this, that, those; NO YES

Slide 63

Slide 63 text

common pitfalls @interface MyNewClass @end @interface MyNewClass : NSObject @end NO YES

Slide 64

Slide 64 text

common pitfalls start writing implementation right away always declare methods in header first then implement NO YES

Slide 65

Slide 65 text

just do it!

Slide 66

Slide 66 text

thanks!