Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
LocateMe: Version 4.0, 2014-09-17
Updated for iOS 8 SDK. Now uses storyboards. This demonstrates the two primary use cases for the Core Location Framework: getting the user's location and tracking changes to the user's location. Signed-off-by: Liu Lantao <liulantao@gmail.com>
- Loading branch information
Showing
26 changed files
with
2,119 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Sample code project: LocateMe | ||
Version: 4.0 | ||
|
||
IMPORTANT: This Apple software is supplied to you by Apple | ||
Inc. ("Apple") in consideration of your agreement to the following | ||
terms, and your use, installation, modification or redistribution of | ||
this Apple software constitutes acceptance of these terms. If you do | ||
not agree with these terms, please do not use, install, modify or | ||
redistribute this Apple software. | ||
|
||
In consideration of your agreement to abide by the following terms, and | ||
subject to these terms, Apple grants you a personal, non-exclusive | ||
license, under Apple's copyrights in this original Apple software (the | ||
"Apple Software"), to use, reproduce, modify and redistribute the Apple | ||
Software, with or without modifications, in source and/or binary forms; | ||
provided that if you redistribute the Apple Software in its entirety and | ||
without modifications, you must retain this notice and the following | ||
text and disclaimers in all such redistributions of the Apple Software. | ||
Neither the name, trademarks, service marks or logos of Apple Inc. may | ||
be used to endorse or promote products derived from the Apple Software | ||
without specific prior written permission from Apple. Except as | ||
expressly stated in this notice, no other rights or licenses, express or | ||
implied, are granted by Apple herein, including but not limited to any | ||
patent rights that may be infringed by your derivative works or by other | ||
works in which the Apple Software may be incorporated. | ||
|
||
The Apple Software is provided by Apple on an "AS IS" basis. APPLE | ||
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND | ||
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. | ||
|
||
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL | ||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, | ||
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED | ||
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), | ||
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
|
||
Copyright (C) 2014 Apple Inc. All Rights Reserved. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
Copyright (C) 2014 Apple Inc. All Rights Reserved. | ||
See LICENSE.txt for this sample’s licensing information | ||
Abstract: | ||
The application delegate has a minimal role in this sample: in -applicationDidFinishLaunching: it adds the tab bar controller's view to the window. It also creates a CLLocationManager object to check the locationServicesEnabled property at launch time. | ||
*/ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface AppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
|
||
@end |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Copyright (C) 2014 Apple Inc. All Rights Reserved. | ||
See LICENSE.txt for this sample’s licensing information | ||
*/ | ||
|
||
#import "AppDelegate.h" | ||
#import <CoreLocation/CoreLocation.h> | ||
|
||
@implementation AppDelegate | ||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | ||
{ | ||
if (![CLLocationManager locationServicesEnabled]) { | ||
// location services is disabled, alert user | ||
UIAlertView *servicesDisabledAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"DisabledTitle", @"DisabledTitle") | ||
message:NSLocalizedString(@"DisabledMessage", @"DisabledMessage") | ||
delegate:nil | ||
cancelButtonTitle:NSLocalizedString(@"OKButtonTitle", @"OKButtonTitle") | ||
otherButtonTitles:nil]; | ||
[servicesDisabledAlert show]; | ||
} | ||
return YES; | ||
} | ||
|
||
@end |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
Copyright (C) 2014 Apple Inc. All Rights Reserved. | ||
See LICENSE.txt for this sample’s licensing information | ||
Abstract: | ||
This is an Objective C category on the CLLocation class that extends the class by adding some convenience methods for presenting localized string representations of various properties. | ||
*/ | ||
|
||
#import <CoreLocation/CoreLocation.h> | ||
|
||
@interface CLLocation (Strings) | ||
|
||
- (NSString *)localizedCoordinateString; | ||
- (NSString *)localizedAltitudeString; | ||
- (NSString *)localizedHorizontalAccuracyString; | ||
- (NSString *)localizedVerticalAccuracyString; | ||
- (NSString *)localizedCourseString; | ||
- (NSString *)localizedSpeedString; | ||
|
||
@end |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
Copyright (C) 2014 Apple Inc. All Rights Reserved. | ||
See LICENSE.txt for this sample’s licensing information | ||
*/ | ||
|
||
#import "CLLocation+Strings.h" | ||
|
||
@implementation CLLocation (Strings) | ||
|
||
- (NSString *)localizedCoordinateString { | ||
if (self.horizontalAccuracy < 0) { | ||
return NSLocalizedString(@"DataUnavailable", @"DataUnavailable"); | ||
} | ||
NSString *latString = (self.coordinate.latitude < 0) ? NSLocalizedString(@"South", @"South") : NSLocalizedString(@"North", @"North"); | ||
NSString *lonString = (self.coordinate.longitude < 0) ? NSLocalizedString(@"West", @"West") : NSLocalizedString(@"East", @"East"); | ||
return [NSString stringWithFormat:NSLocalizedString(@"LatLongFormat", @"LatLongFormat"), fabs(self.coordinate.latitude), latString, fabs(self.coordinate.longitude), lonString]; | ||
} | ||
|
||
- (NSString *)localizedAltitudeString { | ||
if (self.verticalAccuracy < 0) { | ||
return NSLocalizedString(@"DataUnavailable", @"DataUnavailable"); | ||
} | ||
NSString *seaLevelString = (self.altitude < 0) ? NSLocalizedString(@"BelowSeaLevel", @"BelowSeaLevel") : NSLocalizedString(@"AboveSeaLevel", @"AboveSeaLevel"); | ||
return [NSString stringWithFormat:NSLocalizedString(@"AltitudeFormat", @"AltitudeFormat"), fabs(self.altitude), seaLevelString]; | ||
} | ||
|
||
- (NSString *)localizedHorizontalAccuracyString { | ||
if (self.horizontalAccuracy < 0) { | ||
return NSLocalizedString(@"DataUnavailable", @"DataUnavailable"); | ||
} | ||
return [NSString stringWithFormat:NSLocalizedString(@"AccuracyFormat", @"AccuracyFormat"), self.horizontalAccuracy]; | ||
} | ||
|
||
- (NSString *)localizedVerticalAccuracyString { | ||
if (self.verticalAccuracy < 0) { | ||
return NSLocalizedString(@"DataUnavailable", @"DataUnavailable"); | ||
} | ||
return [NSString stringWithFormat:NSLocalizedString(@"AccuracyFormat", @"AccuracyFormat"), self.verticalAccuracy]; | ||
} | ||
|
||
- (NSString *)localizedCourseString { | ||
if (self.course < 0) { | ||
return NSLocalizedString(@"DataUnavailable", @"DataUnavailable"); | ||
} | ||
return [NSString stringWithFormat:NSLocalizedString(@"CourseFormat", @"CourseFormat"), self.course]; | ||
} | ||
|
||
- (NSString *)localizedSpeedString { | ||
if (self.speed < 0) { | ||
return NSLocalizedString(@"DataUnavailable", @"DataUnavailable"); | ||
} | ||
return [NSString stringWithFormat:NSLocalizedString(@"SpeedFormat", @"SpeedFormat"), self.speed]; | ||
} | ||
|
||
@end |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
Copyright (C) 2014 Apple Inc. All Rights Reserved. | ||
See LICENSE.txt for this sample’s licensing information | ||
Abstract: | ||
Attempts to acquire a location measurement with a specific level of accuracy. A timeout is used to avoid wasting power in the case where a sufficiently accurate measurement cannot be acquired. Presents a SetupViewController instance so the user can configure the desired accuracy and timeout. Uses a LocationDetailViewController instance to drill down into details for a given location measurement. | ||
*/ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface GetLocationViewController : UIViewController | ||
|
||
@end |
Oops, something went wrong.