While trying to link my view controller to a delegate class (that implements CLLocation call backs), I am getting an error when initializing my delegate.
My VC.h:
@interface ViewController : UIViewController <MyLocationControllerDelegate> {
MyLocationController *CLController;
}
Instantiating MyLocationController in the main VC.m:
CLController = [[MyLocationController alloc] init]; CLController.locationManager.delegate = self; [CLController.locationManager requestWhenInUseAuthorization]; CLController.locationManager.distanceFilter = kCLDistanceFilterNone; CLController.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; [CLController.locationManager startUpdatingLocation];
The class header file:
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@protocol MyLocationControllerDelegate;
@interface MyLocationController: NSObject {
CLLocationManager *locationManager;
__weak id delegate;
}
@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, weak) id delegate;
@end
and .m file (where I get the error):
- (id)init
{
self = [super init];
if(self != nil) {
self.locationManager = [[CLLocationManager alloc] init]; // Create new instance of locationManager
self.locationManager.delegate = self; // Set the delegate as self.
}
return self;
}
I noticed that this error does not show up in previous iOS versions.
Thanks for the help.