#import <Foundation/Foundation.h>
#import "Weather.h"

// I am going to call these methods on you...
@protocol WeatherServiceDelegate <NSObject>
-(void)didFetchWeather:(Weather *)weather;

// this is where you register yourself with me
@interface WeatherService : NSObject
@property (nonatomic, weak) id <WeatherServiceDelegate> delegate;


#import "WeatherService.h"

@implementation WeatherService

    // fake weather for now
    Weather *weather = [[Weather alloc] init];
    weather.currentTemperature = -20;

    if ([self.delegate respondsToSelector:@selector(didFetchWeather:)]) {
        [self.delegate didFetchWeather:weather];



#import "WeatherService.h"
#import "ViewController.h"

@interface ViewController () <WeatherServiceDelegate>
@property (weak, nonatomic) IBOutlet UILabel *currentTempLabel;

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    WeatherService *tempWeatherService = [[WeatherService alloc] init];

    // register ourselves as a delegate for the weather service
    tempWeatherService.delegate = self;

    // call the service - which is in turn calling us...
    [tempWeatherService fetchWeather];

-(void)didFetchWeather:(Weather *)weather {
    self.currentTempLabel.text = [NSString stringWithFormat:@"%d", weather.currentTemperature];