Skip to content

Instantly share code, notes, and snippets.

@tatsuro-ueda
Created June 7, 2012 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatsuro-ueda/2888758 to your computer and use it in GitHub Desktop.
Save tatsuro-ueda/2888758 to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
CLLocationManager *locationManager;
}
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// ロケーションマネージャーを生成する
locationManager = [[CLLocationManager alloc] init];
// ロケーションマネージャーを設定する
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
// 位置情報の検出をすぐに開始する
[locationManager startUpdatingLocation];
return YES;
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@"%@", newLocation);
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
NSLog(@"Could not find location: %@", error);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment