A couple of weekends ago I had the privelage of attending the iPhone dev school put on by robots and pencils, and taught by JR and Paul.

It was a fun weekend with a tonne of content packed in to 2 days. Here are a few of my notes from the course.

MVC

Method Invocation

Greeting greeting = [[Greeting alloc] init];
 [greeting greet:@"hello world" name:@"Mo"]
 [greeting greet:@"hello world"]

 @implementation Greeting
 -(void)greet:(NSString *)title name:(NSString *)name
 {
 }
 end

Header File

@protocol TempWeatherServiceDelegate <NSObject>
-(void)didFetchWeather:(Weather *)weather;
end

@interface TempWeatherService : NSObject
-(void)fetchWeather;
@property (nonatomic, weak) id <TempWeatherServiceDelegate> delegate;
end

Implementation File

@implementation TempWeatherService

@synthesize delegate = _delegate;

-(void)fetchWeather
{
  Weather *weather = [[Weather alloc] init];
  weather.currentTemperature = -20;
  [self.delegate didFetchWeather:weather]
}

Protocols and Delegates

TempWeatherService service = [[TempWeatherService alloc] init];
 service.delegate = self;
 [service fetchWeather]

Notifications (event aggregator)

[NSNotificationCenter defaultCenter]
-(void)addObserver:(id)observer selector:(SEL)methodToCallIfSomethingHappens name:(NSString)name object:(id)sender

resources

comments powered by Disqus