Garage Days Return:
 Agile iPhone Development
Do you remember this?
Do you remember this?
Do you remember this?
A kid with a good idea...
Manic Miner
The big guys...
But...
These changed the rules...
What do you need to
      start?
A Mac
XCode
An iPhone...
Books
But...
OMG It’s ObjectiveC!
Bigino ObjectiveC
Smalltalk
C
Classes: declaration

#import <Cocoa/Cocoa.h>

@interface Photo : NSObject {
   NSString* caption;
   NSString* photographer;
}
- (NSString*) caption;
- (NSString*) photographer;

- (void) setCaption: (NSString*)input;
- (void) setPhotographer: (NSString*)input;

@end
Classes: implementation

    #import "Photo.h"

    @implementation Photo

    // ...

    - (NSString*) caption {
       return caption;
    }

    - (NSString*) photographer {
       return photographer;
    }

    @end
Method Invocation



photo = [[Photo alloc] init];

[photo setCaption:@"Day at the Beach"];

output = [photo caption];
First Reaction
The Same in Java



photo = new Photo();

photo.setCaption("Day at the Beach");

output = photo.caption();
In ObjectiveC



photo = [[Photo alloc] init];

[photo setCaption:@"Day at the Beach"];

output = [photo caption];
Message Passing




  [obj method:parameter];
Multiple Parameters


- (void)insertObject:(id)anObject atIndex:(NSUInteger)index;


//...


[array insertObject:@"Hello, World!" atIndex:5];
If you want...


- (void)insertObject:(id)anObject :(NSUInteger)index;


//...


[array insertObject:@"Hello, World!" :5];
Dynamic Invocation


(id)anObject = [ factory getFor:par1 ]

[array foo];
[array bar];
No garbage collection!
Counter based
message     counter
   alloc        +1
   copy         +1
  retain        +1
  release       -1
autorelease     -1
If you’ll use an object

   take ownership

      retain
If you own an object

  should release it

     release
If you alloc or copy an object

        you own it

        release
Collections take ownership
- (void)printHello {
   NSString *string;

    string = [[NSString alloc] initWithString:@"Hello"];

    NSLog(string);

    [string release];
}
- (void)printHello {
 NSString *string;


 string = [NSString stringWithFormat:@"Hello"];


 NSLog(string);
}
- (void)printWindowTitle {
   NSString *string;

    string = [myWindow title];

    NSLog(string);
}
NSMutableArray *array;
NSUInteger i;
// ...
for (i = 0; i < 10; i++) {
   NSNumber *allocedNumber = [[NSNumber alloc] initWithInteger: i];
   [array addObject:allocedNumber];
   [allocedNumber release];
}
Be Careful!
What about the tests?
Unit Tests...
Former SenTestingKit



        OCUnit
TestCase Definition

#import <SenTestingKit/SenTestingKit.h>
#import "RpnCalculator.h"

@interface RpnCalculatorTestCase : SenTestCase {

 RpnCalculator* rpnCalculator;
}

@end
TestCase Implementation

@implementation RpnCalculatorTestCase

-(void)setUp{

 rpnCalculator = [[RpnCalculator alloc]init];
}

-(void)tearDown{
  [rpnCalculator release];
}

-(void)testShouldDisplayTwoNumbersWhenNumbersAreSeparatedByEnter{

 [rpnCalculator put:@"1"];

 [rpnCalculator put:@"enter"];

 [rpnCalculator put:@"2"];


 STAssertEqualObjects(@"1n2",rpnCalculator.display,nil);
}
TestCase Implementation


#define   STAssertNil(a1, description, ...)
#define   STAssertNotNil(a1, description, ...)
#define   STAssertTrue(expression, description, ...)
#define   STAssertFalse(expression, description, ...)
#define   STAssertEqualObjects(a1, a2, description, ...)
#define   STAssertEquals(a1, a2, description, ...)
#define   STFail(description, ...)
#define   STAssertTrueNoThrow(expression, description, ...)
#define   STAssertFalseNoThrow(expression, description, ...)

//....
XCode Integration
XCode Integration
XCode in a Nutshell
Useful Shortcuts



Esc - Name Completion
Useful Shortcuts



⌘S - Save
Useful Shortcuts



⌘B - Build
Useful Shortcuts



⌥⌘↑ - HeaderSource
Conclusions
The Market Asks For Apps
The Market Asks For Apps
More Apps...
More Apps...
More Apps!
Lot to Improve
Be Good Kids:
Test First!
Questions?
Coding Dojo Rules
Randori
Silence
Suggest
KataRpnCalculator
20 5 /          => (20/5)      = 4
4 2 + 3 -       => (4+2)-3     = 3
3 5 8 * 7 + *   => 3*((5*8)+7) = 141
Let’s Start!

Agile Iphone Development