First please take a look at codes below
CoreLocationController.h
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@protocol CoreLocationControllerDelegate // Line 1
@required
- (void)locationUpdate:(CLLocation *)location;
- (void)locationError:(NSError *)error;
@end
/* Declare class named CoreLocationControll and inherited from CLLocationManagerDelegate */
@interface CoreLocationController : NSObject <CLLocationManagerDelegate> {
CLLocationManager *locMgr;
id delegate;
}
@property (nonatomic, retain) CLLocationManager *locMgr; // claim setter and getter for locMgr
@property (nonatomic, assign) id delegate; // claim setter and getter for delegate
@end
CoreLcationController.m
#import "CoreLocationController.h"
@implementation CoreLocationController
@synthesize locMgr, delegate;
/* Is triggered by - (void)startUpdatingLocation from CoreLocationDemoViewController.m*/
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"CORE_LOCATION_CONTROLLER=======>DID_UPDATE_TO_LOCATION");
if([self.delegate conformsToProtocol:@protocol(CoreLocationControllerDelegate)]) // line 2
[self.delegate locationUpdate:newLocation];
}
My questions are what line 1 and line 2 do and why I looked up CoreLocationControllerDelegate but no reference on it