Created
April 8, 2011 09:37
-
-
Save logicaroma/909557 to your computer and use it in GitHub Desktop.
A Helper Class which is used in the iOS Sample Project LocateMe. It basically extends the CLLocation with NSString representation.
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
#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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment