Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // CLLocationManager+TemporaryHack.h
- // Created by Joe D'Andrea (@jdandrea) on 9/14/11.
- //
- // Based on code seen on StackOverflow.com and the Big Nerd Ranch forum.
- // http://stackoverflow.com/questions/6792061/how-to-solve-xcode-4-1-lion-gps-error
- //
- // This appears to be necessary for iOS Simulator 4.3 (238.2). So there. :)
- // It's lovingly brute force. Use/improve/share as you wish - cheers!
- //
- #import <Foundation/Foundation.h>
- #import <CoreLocation/CoreLocation.h>
- #if TARGET_IPHONE_SIMULATOR
- @interface CLLocationManager (TemporaryHack)
- @end
- #endif
- //
- // CLLocationManager+TemporaryHack.m
- // Created by Joe D'Andrea (@jdandrea) on 9/14/11.
- //
- // Based on code seen on StackOverflow.com and the Big Nerd Ranch forum.
- // http://stackoverflow.com/questions/6792061/how-to-solve-xcode-4-1-lion-gps-error
- //
- // This appears to be necessary for iOS Simulator 4.3 (238.2). So there. :)
- // It's lovingly brute force. Use/improve/share as you wish - cheers!
- //
- // Adjust to taste.
- #define kLatitude (37.331676)
- #define kLongitude (-122.030393)
- #import "CLLocationManager+TemporaryHack.h"
- #if TARGET_IPHONE_SIMULATOR
- @interface CLHeading (TemporaryHack)
- - (id)init;
- @end
- @implementation CLHeading (TemporaryHack)
- - (id)init { if ((self = [super init])) { } return self; }
- - (CLLocationDirection)magneticHeading { return 0.0; }
- - (CLLocationDirection)trueHeading { return 0.0; }
- - (CLLocationDirection)headingAccuracy { return 0.0; }
- - (NSDate *)timestamp { return [NSDate date]; }
- @end
- @implementation CLLocationManager (TemporaryHack)
- - (void)hackLocationFix {
- CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(kLatitude, kLongitude);
- CLLocation *location = [[CLLocation alloc] initWithCoordinate:coordinate altitude:0.0 horizontalAccuracy:0.0 verticalAccuracy:0.0 timestamp:[NSDate date]];
- [[self delegate] locationManager:self didUpdateToLocation:location fromLocation:nil];
- }
- - (void)hackHeadingFix {
- [[self delegate] locationManager:self didUpdateHeading:[[[CLHeading alloc] init] autorelease]];
- }
- - (void)startUpdatingLocation {
- [self performSelector:@selector(hackLocationFix) withObject:nil afterDelay:0.1];
- }
- - (void)startUpdatingHeading {
- [self performSelector:@selector(hackHeadingFix) withObject:nil afterDelay:0.1];
- }
- + (BOOL)locationServicesEnabled { return YES; }
- - (BOOL)locationServicesEnabled { return [CLLocationManager locationServicesEnabled]; }
- + (BOOL)headingAvailable { return YES; }
- - (BOOL)headingAvailable { return [CLLocationManager headingAvailable]; }
- @end
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement