Skip to content

Commit 130c626

Browse files
committed
Added CoreLocationSample
1 parent 1149a22 commit 130c626

10 files changed

+1137
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// CoreLocationSampleAppDelegate.h
3+
// CoreLocationSample
4+
//
5+
// Created by Hiroshi Hashiguchi on 10/10/20.
6+
// Copyright 2010 . All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@class CoreLocationSampleViewController;
12+
13+
@interface CoreLocationSampleAppDelegate : NSObject <UIApplicationDelegate> {
14+
UIWindow *window;
15+
CoreLocationSampleViewController *viewController;
16+
}
17+
18+
@property (nonatomic, retain) IBOutlet UIWindow *window;
19+
@property (nonatomic, retain) IBOutlet CoreLocationSampleViewController *viewController;
20+
21+
@end
22+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//
2+
// CoreLocationSampleAppDelegate.m
3+
// CoreLocationSample
4+
//
5+
// Created by Hiroshi Hashiguchi on 10/10/20.
6+
// Copyright 2010 . All rights reserved.
7+
//
8+
9+
#import "CoreLocationSampleAppDelegate.h"
10+
#import "CoreLocationSampleViewController.h"
11+
12+
@implementation CoreLocationSampleAppDelegate
13+
14+
@synthesize window;
15+
@synthesize viewController;
16+
17+
18+
#pragma mark -
19+
#pragma mark Application lifecycle
20+
21+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
22+
23+
// Override point for customization after application launch.
24+
25+
// Add the view controller's view to the window and display.
26+
[window addSubview:viewController.view];
27+
[window makeKeyAndVisible];
28+
29+
return YES;
30+
}
31+
32+
33+
- (void)applicationWillResignActive:(UIApplication *)application {
34+
/*
35+
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
36+
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
37+
*/
38+
}
39+
40+
41+
- (void)applicationDidEnterBackground:(UIApplication *)application {
42+
/*
43+
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
44+
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
45+
*/
46+
}
47+
48+
49+
- (void)applicationWillEnterForeground:(UIApplication *)application {
50+
/*
51+
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
52+
*/
53+
}
54+
55+
56+
- (void)applicationDidBecomeActive:(UIApplication *)application {
57+
/*
58+
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
59+
*/
60+
}
61+
62+
63+
- (void)applicationWillTerminate:(UIApplication *)application {
64+
/*
65+
Called when the application is about to terminate.
66+
See also applicationDidEnterBackground:.
67+
*/
68+
}
69+
70+
71+
#pragma mark -
72+
#pragma mark Memory management
73+
74+
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
75+
/*
76+
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
77+
*/
78+
}
79+
80+
81+
- (void)dealloc {
82+
[viewController release];
83+
[window release];
84+
[super dealloc];
85+
}
86+
87+
88+
@end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// CoreLocationSampleViewController.h
3+
// CoreLocationSample
4+
//
5+
// Created by Hiroshi Hashiguchi on 10/10/20.
6+
// Copyright 2010 . All rights reserved.
7+
//
8+
#import <UIKit/UIKit.h>
9+
#import <CoreLocation/CoreLocation.h>
10+
11+
@interface CoreLocationSampleViewController : UIViewController <CLLocationManagerDelegate> {
12+
13+
CLLocationManager* locationManager_;
14+
}
15+
16+
@property (nonatomic, retain) CLLocationManager* locationManager;
17+
@end
18+
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// CoreLocationSampleViewController.m
3+
// CoreLocationSample
4+
//
5+
// Created by Hiroshi Hashiguchi on 10/10/20.
6+
// Copyright 2010 . All rights reserved.
7+
//
8+
9+
#import "CoreLocationSampleViewController.h"
10+
11+
@implementation CoreLocationSampleViewController
12+
13+
@synthesize locationManager = locationManager_;
14+
15+
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
16+
- (void)viewDidLoad {
17+
[super viewDidLoad];
18+
19+
if ([CLLocationManager locationServicesEnabled]) {
20+
self.locationManager = [[CLLocationManager alloc] init];
21+
self.locationManager.delegate = self;
22+
[self.locationManager startUpdatingLocation];
23+
NSLog(@"Start updating location.");
24+
25+
} else {
26+
NSLog(@"The location services is disabled.");
27+
}
28+
29+
/* for iPad (iOS 3.2)
30+
self.locationManager = [[CLLocationManager alloc] init];
31+
self.locationManager.delegate = self;
32+
[self.locationManager startUpdatingLocation];
33+
NSLog(@"Start updating location.");
34+
*/
35+
}
36+
37+
38+
/*
39+
// Override to allow orientations other than the default portrait orientation.
40+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
41+
// Return YES for supported orientations
42+
return (interfaceOrientation == UIInterfaceOrientationPortrait);
43+
}
44+
*/
45+
46+
- (void)didReceiveMemoryWarning {
47+
// Releases the view if it doesn't have a superview.
48+
[super didReceiveMemoryWarning];
49+
50+
// Release any cached data, images, etc that aren't in use.
51+
}
52+
53+
- (void)viewDidUnload {
54+
self.locationManager = nil;
55+
56+
}
57+
58+
59+
- (void)dealloc {
60+
self.locationManager = nil;
61+
[super dealloc];
62+
}
63+
64+
#pragma mark -
65+
#pragma mark CLLocationManagerDelegate
66+
- (void)logLocation:(CLLocation*)location
67+
{
68+
CLLocationCoordinate2D coordinate = location.coordinate;
69+
NSLog(@"----------------------------------------------------");
70+
NSLog(@"latitude,logitude : %f, %f", coordinate.latitude, coordinate.longitude);
71+
NSLog(@"altitude : %f", location.altitude);
72+
NSLog(@"cource : %f", location.course);
73+
NSLog(@"horizontalAccuracy: %f", location.horizontalAccuracy);
74+
NSLog(@"verticalAccuracy : %f", location.verticalAccuracy);
75+
NSLog(@"speed : %f", location.speed);
76+
NSLog(@"timestamp : %@", location.timestamp);
77+
}
78+
79+
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
80+
81+
[self logLocation:newLocation];
82+
}
83+
84+
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
85+
NSLog(@"Error: %@", error);
86+
}
87+
88+
89+
@end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>UIApplicationExitsOnSuspend</key>
6+
<true/>
7+
<key>CFBundleDevelopmentRegion</key>
8+
<string>English</string>
9+
<key>CFBundleDisplayName</key>
10+
<string>${PRODUCT_NAME}</string>
11+
<key>CFBundleExecutable</key>
12+
<string>${EXECUTABLE_NAME}</string>
13+
<key>CFBundleIconFile</key>
14+
<string></string>
15+
<key>CFBundleIdentifier</key>
16+
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
17+
<key>CFBundleInfoDictionaryVersion</key>
18+
<string>6.0</string>
19+
<key>CFBundleName</key>
20+
<string>${PRODUCT_NAME}</string>
21+
<key>CFBundlePackageType</key>
22+
<string>APPL</string>
23+
<key>CFBundleSignature</key>
24+
<string>????</string>
25+
<key>CFBundleVersion</key>
26+
<string>1.0</string>
27+
<key>LSRequiresIPhoneOS</key>
28+
<true/>
29+
<key>NSMainNibFile</key>
30+
<string>MainWindow</string>
31+
</dict>
32+
</plist>

0 commit comments

Comments
 (0)