Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Ariejan de Vroom • @ariejan • http://ariejan.net
 Kabisa • @kabisaict • http://kabisa.nl

Slide 4

Slide 4 text

Ruby Ariejan de Vroom • @ariejan • http://ariejan.net
 Kabisa • @kabisaict • http://kabisa.nl

Slide 5

Slide 5 text

Objective-C Ariejan de Vroom • @ariejan • http://ariejan.net
 Kabisa • @kabisaict • http://kabisa.nl

Slide 6

Slide 6 text

… but why?

Slide 7

Slide 7 text

A Short History Of
 Programming Languages

Slide 8

Slide 8 text

The Influence of Smalltalk

Slide 9

Slide 9 text

#('a' 'b' 'c' ) do:[:each | Transcript show: each. Transcript cr. ].

Slide 10

Slide 10 text

Ruby Objective-C

Slide 11

Slide 11 text

Dynamically Typed
 Object Oriented
 Programming Languages

Slide 12

Slide 12 text

Dynamic Dispatching via Message Dispatching

Slide 13

Slide 13 text

@post.publish @post.send(:publish)

Slide 14

Slide 14 text

[post publish]; [post performSelector:@selector(publish)];

Slide 15

Slide 15 text

Objective-C is a Super Set of C

Slide 16

Slide 16 text

Objective-C is an Compiled Language

Slide 17

Slide 17 text

Objective-C has Forward Declarations

Slide 18

Slide 18 text

Objective-C has Macro’s

Slide 19

Slide 19 text

Objective-C has Pointers

Slide 20

Slide 20 text

Objective-C requires Manual Memory Management

Slide 21

Slide 21 text

Objective-C has Threading

Slide 22

Slide 22 text

Ruby is an Interpreted Language

Slide 23

Slide 23 text

Ruby has Duck-Typing

Slide 24

Slide 24 text

Ruby has No Pointers

Slide 25

Slide 25 text

Ruby does not require Manual Memory Management

Slide 26

Slide 26 text

Ruby does not require Manual Memory Management

Slide 27

Slide 27 text

Ruby has a Garbage Collector

Slide 28

Slide 28 text

Ruby has (broken) Threading

Slide 29

Slide 29 text

Objective-C Cocoa AppKit FoundationKit Cocoa Touch AppKit FoundationKit Mac OS X App iOS App Programming Stack

Slide 30

Slide 30 text

// ADVPerson.h ! #import #import "ADVDepartment.h" ! @interface ADVPerson : NSObject { } ! @property (copy, nonatomic) NSString *name; @property (strong, nonatomic) ADVDepartment *department; @property (readonly, nonatomic) NSNumber *salary; ! + (ADVPerson *)personWithRandomData; ! - (void)giveRaiseOf:(NSNumber)amount withReason:(NSString *)reason; ! @end

Slide 31

Slide 31 text

// ADVPerson.h ! #import #import "ADVDepartment.h" ! @interface ADVPerson : NSObject { } ! @property (copy, nonatomic) NSString *name; @property (strong, nonatomic) ADVDepartment *department; @property (readonly, nonatomic) NSNumber *salary; ! + (ADVPerson *)personWithRandomData; ! - (void)giveRaiseOf:(NSNumber)amount withReason:(NSString *)reason; ! @end

Slide 32

Slide 32 text

// ADVPerson.h ! #import #import "ADVDepartment.h" ! @interface ADVPerson : NSObject { } ! @property (copy, nonatomic) NSString *name; @property (strong, nonatomic) ADVDepartment *department; @property (readonly, nonatomic) NSNumber *salary; ! + (ADVPerson *)personWithRandomData; ! - (void)giveRaiseOf:(NSNumber)amount withReason:(NSString *)reason; ! @end

Slide 33

Slide 33 text

// ADVPerson.h ! #import #import "ADVDepartment.h" ! @interface ADVPerson : NSObject { } ! @property (copy, nonatomic) NSString *name; @property (strong, nonatomic) ADVDepartment *department; @property (readonly, nonatomic) NSNumber *salary; ! + (ADVPerson *)personWithRandomData; ! - (void)giveRaiseOf:(NSNumber)amount withReason:(NSString *)reason; ! @end

Slide 34

Slide 34 text

ADVPerson *person = [ADVPerson personWithRandomData]; [person giveRaiseOf:1000 withReason:@"For being awesome!"];

Slide 35

Slide 35 text

// ADVPerson.m ! #import "ADVPerson.h" ! @interface ADVPerson () @end ! @implementation ADVPerson ! + (ADVPerson *)personWithRandomData { ADVPerson *person = [[ADVPerson alloc] init]; [person setName:@"John Doe"]; [person setDepartment:[ADVDepartment randomDepartment]]; [person giveRaiseOf:2000 withReason:@"Initial salary"]; return person; } ! - (void)giveRaiseOf:(NSNumber)amount withReason:(NSString *)reason { _salary = _salary + amount; NSLog(@"Raising salary to %@ because %@", _salary, reason); } ! @end

Slide 36

Slide 36 text

// ADVPerson.m ! #import "ADVPerson.h" ! @interface ADVPerson () @end ! @implementation ADVPerson ! + (ADVPerson *)personWithRandomData { ADVPerson *person = [[ADVPerson alloc] init]; [person setName:@"John Doe"]; [person setDepartment:[ADVDepartment randomDepartment]]; [person giveRaiseOf:2000 withReason:@"Initial salary"]; return person; } ! - (void)giveRaiseOf:(NSNumber)amount withReason:(NSString *)reason { _salary = _salary + amount; NSLog(@"Raising salary to %@ because %@", _salary, reason); } ! @end

Slide 37

Slide 37 text

// ADVPerson.m ! #import "ADVPerson.h" ! @interface ADVPerson () - (void)setSalary:(NSNumber)amount; @end ! @implementation ADVPerson ! + (ADVPerson *)personWithRandomData { ADVPerson *person = [[ADVPerson alloc] init]; [person setName:@"John Doe"]; [person setDepartment:[ADVDepartment randomDepartment]]; [person giveRaiseOf:2000 withReason:@"Initial salary"]; return person; } ! - (void)giveRaiseOf:(NSNumber)amount withReason:(NSString *)reason { [self setSalary:(_salary + amount)]; NSLog(@"Raising salary to %@ because %@", _salary, reason); } ! @end

Slide 38

Slide 38 text

// NSString+Reverse.h @interface NSString (Reverse) { } - (NSString *)reverse; @end ! ! ! ! // NSString+Reverse.m @implementation NSString (Reverse) ! - (NSString *)reverse { // TODO: Implement this. } ! @end

Slide 39

Slide 39 text

Memory ADVPerson *john = [ADVPerson personWithRandomData]; ! NSLog(@"Person: %@", john.name); // Person: John Doe The Stack john

Slide 40

Slide 40 text

Memory ADVPerson *john = [ADVPerson personWithRandomData]; ! NSLog(@"Person: %@", john.name); // Person: John Doe ! ADVPerson *dick = john; The Stack john dick

Slide 41

Slide 41 text

Memory ADVPerson *john = [ADVPerson personWithRandomData]; ! NSLog(@"Person: %@", john.name); // Person: John Doe ! ADVPerson *dick = john; [dick setName:@"Dick Doe”]; The Stack john dick

Slide 42

Slide 42 text

Memory ADVPerson *john = [ADVPerson personWithRandomData]; ! NSLog(@"Person: %@", john.name); // Person: John Doe ! ADVPerson *dick = john; [dick setName:@"Dick Doe”]; ! NSLog(@"Person: %@", dick.name); // Person: Dick Doe The Stack john dick

Slide 43

Slide 43 text

Memory ADVPerson *john = [ADVPerson personWithRandomData]; ! NSLog(@"Person: %@", john.name); // Person: John Doe ! ADVPerson *dick = john; [dick setName:@"Dick Doe”]; ! NSLog(@"Person: %@", dick.name); // Person: Dick Doe ! NSLog(@"Person: %@", john.name); // Person: Dick Doe The Stack john dick

Slide 44

Slide 44 text

Mutable Immutable

Slide 45

Slide 45 text

NSCopying NSMutableCopying

Slide 46

Slide 46 text

Reference Counting

Slide 47

Slide 47 text

NSString *s = [[NSString alloc] init]; // Ref count is 1

Slide 48

Slide 48 text

NSString *s = [[NSString alloc] init]; // Ref count is 1 [s retain]; // Ref count is 2

Slide 49

Slide 49 text

NSString *s = [[NSString alloc] init]; // Ref count is 1 [s retain]; // Ref count is 2 [s release]; // Ref count is 1 again

Slide 50

Slide 50 text

NSString *s = [[NSString alloc] init]; // Ref count is 1 [s retain]; // Ref count is 2 [s release]; // Ref count is 1 again [s release]; // Ref count is 0

Slide 51

Slide 51 text

NSString *s = [[NSString alloc] init]; // Ref count is 1 [s retain]; // Ref count is 2 [s release]; // Ref count is 1 again [s release]; // Ref count is 0 s = nil; // Remove our pointer

Slide 52

Slide 52 text

NSString *s = [[NSString alloc] init]; // Ref count is 1 [s retain]; // Ref count is 2 [s release]; // Ref count is 1 again [s release]; // Ref count is 0 s = nil; // Remove our pointer ! ! NSString *s = [NSString stringWithString:@"Hello world"]; // Auto released! [s retain]; // To hang on to s

Slide 53

Slide 53 text

NSString *s = [[NSString alloc] init]; // Ref count is 1 [s retain]; // Ref count is 2 [s release]; // Ref count is 1 again [s release]; // Ref count is 0 s = nil; // Remove our pointer ! ! NSString *s = [NSString stringWithString:@"Hello world"]; // Auto released! [s retain]; // To hang on to s ! ! - (NSString *)helloWorldString { NSString *s = [[NSString alloc] initWithString:@"Hello world!"]; return [s autorelease]; }

Slide 54

Slide 54 text

ARC Automatic Reference Counting

Slide 55

Slide 55 text

@property (strong, nonatomic) ADVDepartment *department; @property (weak, nonatomic) ADVPeopleManager *peopleManager;

Slide 56

Slide 56 text

-fno-objc-arc

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

// ADVPriceFetcher.h #include ! @interface ADVPriceFetcher : NSObject - (NSNumber *)fetchCurrentBitcoinPriceInEur; @end

Slide 59

Slide 59 text

// ADVPriceFetcher.h #include ! @protocol ADVPriceFetcherDelegate - (void)fetchedCurrentBitcoinPriceInEur:(NSNumber *)price; @end ! @interface ADVPriceFetcher : NSObject - (void)fetchCurrentBitcoinPriceInEur; @end

Slide 60

Slide 60 text

// ADVPriceFetcher.h #include ! @protocol ADVPriceFetcherDelegate - (void)fetchedCurrentBitcoinPriceInEur:(NSNumber *)price; @end ! @interface ADVPriceFetcher : NSObject @property (weak, nonatomic) id delegate; - (void)fetchCurrentBitcoinPriceInEur; @end

Slide 61

Slide 61 text

// ADVMainViewController.h #import "ADVPriceFetcher.h" ! @interface ADVMainViewController : UIViewController @property (strong, nonatomic) ADVPriceFetcher *priceFetcher; - (IBAction)pushRefreshButton; @end

Slide 62

Slide 62 text

// ADVMainViewController.m @implementation ADVMainViewController ! - (id)init { if ([super init]) { self.priceFetcher = [[ADVPriceFetcher alloc] init]; [self.priceFetcher setDelegate:self]; } return self; } ! - (IBAction)pushRefreshButton { [self.priceFetcher fetchCurrentBitcoinPriceInEur]; } ! - (void)fetchedCurrentBitcoinPriceInEur:(NSNumber *)price { NSLog(@"Fetch price: %@", price); } ! @end

Slide 63

Slide 63 text

// ADVPriceFetcher.m #import "ADVPriceFetch.h" ! @implementation ADVPriceFetcher ! - (void)fetchCurrentBitcoinPriceInEur { // Work our networking magic. NSNumber *price = /* ... */ if (_delegate && [_delegate respondsToSelector:@selector(fetchedCurrentBitcoinPriceInEur:)]) { [delegate fetchedCurrentBitcoinPriceInEur:price]; } } ! @end

Slide 64

Slide 64 text

@protocol ADVPriceFetcherDelegate - (void)fetchedCurrentBitcoinPriceInEur:(NSNumber *)price; ! @optional - (void)errorFetchingBitcoinPrice:(NSError *)error; ! @end

Slide 65

Slide 65 text

var fetcher = new ADVNetworkFetcher(); fetcher.fetchCurrentBitcoinPriceInEur({ success: function(price) { // … } });

Slide 66

Slide 66 text

- (IBAction)pushRefreshButton { [self.priceFetcher fetchCurrentBitcoinPriceInEur:^(NSNumber *price) { NSLog(@"Fetched price: %@", price) }]; }

Slide 67

Slide 67 text

// ADVPriceFetcher.h #include @interface ADVPriceFetcher : NSObject - (void)fetchCurrentBitcoinPriceInEur:(void (^)(NSNumber *price)completed; @end ! ! // ADVPriceFetcher.m @implementation ADVPriceFetcher ! - (void)fetchCurrentBitcoinPriceInEur:(void (^)(NSNumber *price)completed { // Work our networking magic. NSNumber *price = /* ... */ completed(price); } @end

Slide 68

Slide 68 text

Grand Central Dispatch

Slide 69

Slide 69 text

NSNotificationCenter

Slide 70

Slide 70 text

Xcode

Slide 71

Slide 71 text

iTunes Connect

Slide 72

Slide 72 text

http://developer.apple.com

Slide 73

Slide 73 text

CocoaPods

Slide 74

Slide 74 text

I learned.

Slide 75

Slide 75 text

Mobile Design Is Really Hard™

Slide 76

Slide 76 text

Mobile ≠ Web

Slide 77

Slide 77 text

Think Different

Slide 78

Slide 78 text

I made an app.

Slide 79

Slide 79 text

Binary Deep http://aj.gs/binary-deep

Slide 80

Slide 80 text

Binary Deep http://aj.gs/binary-deep