-
-
Save wizardishungry/5809271 to your computer and use it in GitHub Desktop.
Revisions
-
tmiz revised this gist
Dec 1, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation // $ ./a.out // location service enabled // 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 140.695538 // 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900 // tmiz [email protected] // -
tmiz revised this gist
Dec 1, 2011 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,6 @@ // $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation // $ ./a.out // location service enabled // 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 139.695538 // 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900 // tmiz [email protected] -
tmiz revised this gist
Dec 1, 2011 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,10 +11,8 @@ #import <cocoa/cocoa.h> #import <CoreLocation/CoreLocation.h> @interface NSObject(CB) - (void)logLonLat:(CLLocation*)location; - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation; - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error; -
tmiz created this gist
Dec 1, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ // // Using CoreLocation on Mac OS X with command-line // $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation // $ ./a.out // location service enabled // 2011-12-01 21:03:01.836 a.out[10214:903] ---------------------------------------------------- // 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 139.695538 // 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900 // tmiz [email protected] // #import <cocoa/cocoa.h> #import <CoreLocation/CoreLocation.h> CLLocationManager *manager; @interface NSObject(CB) - (void)logLocation:(CLLocation*)location; - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation; - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error; @end @implementation NSObject(CB) - (void)logLonLat:(CLLocation*)location { CLLocationCoordinate2D coordinate = location.coordinate; NSLog(@"latitude,logitude : %f, %f", coordinate.latitude, coordinate.longitude); NSLog(@"timestamp : %@", location.timestamp); } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self logLonLat:newLocation]; [pool drain]; } - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{ NSLog(@"Error: %@", error); } @end int main(int ac,char *av[]) { id obj = [[NSObject alloc] init]; id lm = nil; if ([CLLocationManager locationServicesEnabled]) { printf("location service enabled\n"); lm = [[CLLocationManager alloc] init]; [lm setDelegate:obj]; [lm startUpdatingLocation]; } CFRunLoopRun(); [lm release]; [obj release]; return 0; }