From d9c3af9787168aebfa9a6413c608d12341e46092 Mon Sep 17 00:00:00 2001 From: Igor Khmurets Date: Mon, 16 Dec 2013 18:17:34 +0300 Subject: [PATCH] Text alignment fixes Comments now are showing in documentation --- api/MapsWithMeAPI.h | 51 +++++++++++++++++++++++---------------------- api/MapsWithMeAPI.m | 31 +++++++++++++++------------ 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/api/MapsWithMeAPI.h b/api/MapsWithMeAPI.h index e761823..41873af 100644 --- a/api/MapsWithMeAPI.h +++ b/api/MapsWithMeAPI.h @@ -28,45 +28,46 @@ #import -#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_3 - #error "MapsWithMe supports iOS >= 4.3 only" +#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 + #error "MapsWithMe supports iOS >= 5.0 only" #endif // Wrapper for a pin on a map @interface MWMPin : NSObject -// [required] pin latitude and longitude +/// [required] pin latitude @property (nonatomic, assign) double lat; +/// [required] pin longitude @property (nonatomic, assign) double lon; -// [optional] pin title +/// [optional] pin title @property (nonatomic, retain) NSString * title; -// [optional] passed back to the app when pin is clicked, OR, if it's a valid url, -// it will be opened from MapsWithMe after selecting "More Details..." for the pin +/// [optional] passed back to the app when pin is clicked, OR, if it's a valid url, +/// it will be opened from MapsWithMe after selecting "More Details..." for the pin @property (nonatomic, retain) NSString * idOrUrl; -- (id) initWithLat:(double)lat lon:(double)lon title:(NSString *)title andId:(NSString *)idOrUrl; +- (id)initWithLat:(double)lat lon:(double)lon title:(NSString *)title andId:(NSString *)idOrUrl; @end // MapsWithMe API interface @interface MWMApi : NSObject -// returns YES if url is received from MapsWithMe and can be parsed -+ (BOOL) isMapsWithMeUrl:(NSURL *)url; -// returns nil if user didn't select any pin and simply pressed "Back" button -+ (MWMPin *) pinFromUrl:(NSURL *)url; -// returns NO if MapsWithMe is not installed or outdated version doesn't support API calls -+ (BOOL) isApiSupported; -// Simply opens MapsWithMe app -+ (BOOL) showMap; -// Displays given point on a map, title and id are optional -// If id contains valid url, it will be opened from MapsWithMe after selecting "More Details..." for the pin -+ (BOOL) showLat:(double)lat lon:(double)lon title:(NSString *)title andId:(NSString *)idOrUrl; -// The same as above but using pin wrapper -+ (BOOL) showPin:(MWMPin *)pin; -// Displays any number of pins -+ (BOOL) showPins:(NSArray *)pins; +/// returns YES if url is received from MapsWithMe and can be parsed ++ (BOOL)isMapsWithMeUrl:(NSURL *)url; +/// returns nil if user didn't select any pin and simply pressed "Back" button ++ (MWMPin *)pinFromUrl:(NSURL *)url; +/// returns NO if MapsWithMe is not installed or outdated version doesn't support API calls ++ (BOOL)isApiSupported; +/// Simply opens MapsWithMe app ++ (BOOL)showMap; +/// Displays given point on a map, title and id are optional. +/// If id contains valid url, it will be opened from MapsWithMe after selecting "More Details..." for the pin ++ (BOOL)showLat:(double)lat lon:(double)lon title:(NSString *)title andId:(NSString *)idOrUrl; +/// The same as above but using pin wrapper ++ (BOOL)showPin:(MWMPin *)pin; +/// Displays any number of pins ++ (BOOL)showPins:(NSArray *)pins; // -+ (void) showMapsWithMeIsNotInstalledDialog; -// Set value = YES if you want to open pin URL on balloon click, default value is NO -+(void) setOpenUrlOnBalloonClick:(BOOL)value; ++ (void)showMapsWithMeIsNotInstalledDialog; +/// Set value = YES if you want to open pin URL on balloon click, default value is NO ++ (void)setOpenUrlOnBalloonClick:(BOOL)value; @end diff --git a/api/MapsWithMeAPI.m b/api/MapsWithMeAPI.m index 0b4e588..4c59076 100644 --- a/api/MapsWithMeAPI.m +++ b/api/MapsWithMeAPI.m @@ -35,7 +35,7 @@ static BOOL openUrlOnBalloonClick = NO; @implementation MWMPin -- (id) init +- (id)init { if ((self = [super init])) { @@ -45,7 +45,7 @@ static BOOL openUrlOnBalloonClick = NO; return self; } -- (id) initWithLat:(double)lat lon:(double)lon title:(NSString *)title andId:(NSString *)idOrUrl +- (id)initWithLat:(double)lat lon:(double)lon title:(NSString *)title andId:(NSString *)idOrUrl { if ((self = [super init])) { @@ -63,23 +63,28 @@ static BOOL openUrlOnBalloonClick = NO; self.idOrUrl = nil; [super dealloc]; } + @end // Utility class to automatically handle "MapsWithMe is not installed" situations @interface MWMNavigationController : UINavigationController + @end + @implementation MWMNavigationController + - (void)onCloseButtonClicked:(id)sender { [self dismissModalViewControllerAnimated:YES]; } + @end @implementation MWMApi // Escape special chars with percent encoding -+ (NSString *) percentEncode:(NSString *)str ++ (NSString *)percentEncode:(NSString *)str { CFStringRef cfStr = (CFStringRef)str; CFStringRef cfEncodedStr = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, cfStr, NULL, CFSTR("&?/:="), kCFStringEncodingUTF8); @@ -88,13 +93,13 @@ static BOOL openUrlOnBalloonClick = NO; return encodedStr; } -+ (BOOL) isMapsWithMeUrl:(NSURL *)url ++ (BOOL)isMapsWithMeUrl:(NSURL *)url { NSString * appScheme = [MWMApi detectBackUrlScheme]; return appScheme && [url.scheme isEqualToString:appScheme]; } -+ (MWMPin *) pinFromUrl:(NSURL *)url ++ (MWMPin *)pinFromUrl:(NSURL *)url { if (![MWMApi isMapsWithMeUrl:url]) return nil; @@ -133,28 +138,28 @@ static BOOL openUrlOnBalloonClick = NO; return pin; } -+ (BOOL) isApiSupported ++ (BOOL)isApiSupported { return [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:MWMUrlScheme]]; } -+ (BOOL) showMap ++ (BOOL)showMap { return [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[MWMUrlScheme stringByAppendingFormat:@"map?v=%d", MAPSWITHME_API_VERSION]]]; } -+ (BOOL) showLat:(double)lat lon:(double)lon title:(NSString *)title andId:(NSString *)idOrUrl ++ (BOOL)showLat:(double)lat lon:(double)lon title:(NSString *)title andId:(NSString *)idOrUrl { MWMPin * pin = [[[MWMPin alloc] initWithLat:lat lon:lon title:title andId:idOrUrl] autorelease]; return [MWMApi showPin:pin]; } -+ (BOOL) showPin:(MWMPin *)pin ++ (BOOL)showPin:(MWMPin *)pin { return [MWMApi showPins:[NSArray arrayWithObject:pin]]; } -+ (BOOL) showPins:(NSArray *)pins ++ (BOOL)showPins:(NSArray *)pins { // Automatic check that MapsWithMe is installed if (![MWMApi isApiSupported]) @@ -194,7 +199,7 @@ static BOOL openUrlOnBalloonClick = NO; return result; } -+ (NSString *) detectBackUrlScheme ++ (NSString *)detectBackUrlScheme { for (NSDictionary * dict in [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"]) { @@ -240,7 +245,7 @@ static NSString * mapsWithMeIsNotInstalledPage = // For gethostbyname below #include -+ (void) showMapsWithMeIsNotInstalledDialog ++ (void)showMapsWithMeIsNotInstalledDialog { UIWebView * webView = [[[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]; // check that we have Internet connection and display fresh online page if possible @@ -257,7 +262,7 @@ static NSString * mapsWithMeIsNotInstalledPage = [[[UIApplication sharedApplication] delegate].window.rootViewController presentModalViewController:navController animated:YES]; } -+(void) setOpenUrlOnBalloonClick:(BOOL)value ++ (void)setOpenUrlOnBalloonClick:(BOOL)value { openUrlOnBalloonClick = value; }