Skip to content

Instantly share code, notes, and snippets.

@veritech
Created March 21, 2010 21:46
Show Gist options
  • Save veritech/339594 to your computer and use it in GitHub Desktop.
Save veritech/339594 to your computer and use it in GitHub Desktop.
//
// CLLocation-Extras.m
//
// Created by Jonathan Dalrymple on 21/03/2010.
// Copyright 2010 Float:Right. All rights reserved.
//
#import "CLLocation-Extras.h"
@implementation CLLocationManager(Extras)
/*
Convience method
*/
+(CLLocationManager*) sharedInstance{
id appDelegate;
appDelegate = [[UIApplication sharedApplication] delegate];
//Does the delegate respond?
if( [appDelegate respondsToSelector:@selector( locationManager)] ){
NSLog(@"[CLLocationManager] create instance");
//Create a delegate if required
if( [appDelegate locationManager] == nil ){
[appDelegate setLocationManager:[[CLLocationManager alloc] init]];
}
//Return an instance
return [appDelegate locationManager];
}
else{
NSLog(@"[CLLocationManager] Property not found on AppDelegate");
return nil;
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment