Skip to content

Commit

Permalink
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
Lax committed Feb 13, 2018
1 parent d7fae3d commit efa24f7
Show file tree
Hide file tree
Showing 26 changed files with 2,119 additions and 0 deletions.
42 changes: 42 additions & 0 deletions LocateMe/LICENSE.txt
@@ -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.
366 changes: 366 additions & 0 deletions LocateMe/LocateMe.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions LocateMe/LocateMe/AppDelegate.h
@@ -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
26 changes: 26 additions & 0 deletions LocateMe/LocateMe/AppDelegate.m
@@ -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
22 changes: 22 additions & 0 deletions LocateMe/LocateMe/CLLocation+Strings.h
@@ -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
56 changes: 56 additions & 0 deletions LocateMe/LocateMe/CLLocation+Strings.m
@@ -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
15 changes: 15 additions & 0 deletions LocateMe/LocateMe/GetLocationViewController.h
@@ -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

0 comments on commit efa24f7

Please sign in to comment.