[ios][api] Renamed properties and method names

This commit is contained in:
Alex Zolotarev 2013-07-05 11:21:39 +03:00 committed by Alex Zolotarev
parent b741fee534
commit 6bd8e4e2d4
5 changed files with 22 additions and 22 deletions

View file

@ -38,11 +38,11 @@
@property (nonatomic, assign) double lat;
@property (nonatomic, assign) double lon;
// [optional] pin title
@property (nonatomic, retain) NSString * optionalTitle;
@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
@property (nonatomic, retain) NSString * optionalId;
- (id) initWithLat:(double)lat lon:(double)lon title:(NSString *)title id:(NSString *)pinId;
@property (nonatomic, retain) NSString * idOrUrl;
- (id) initWithLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl;
@end
@ -51,7 +51,7 @@
// returns YES if url is received from MapsWithMe and can be parsed
+ (BOOL) isMapsWithMeUrl:(NSURL *)url;
// returns nil if received url is invalid or not from MapsWithMe
// 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;
@ -59,7 +59,7 @@
+ (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 *)optionalTitle id:(NSString *)optionalId;
+ (BOOL) showLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl;
// The same as above but using pin wrapper
+ (BOOL) showPin:(MWMPin *)pin;
// Displays any number of pins

View file

@ -44,22 +44,22 @@ static NSString * MWMUrlScheme = @"mapswithme://";
return self;
}
- (id) initWithLat:(double)lat lon:(double)lon title:(NSString *)title id:(NSString *)pinId
- (id) initWithLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl
{
if ((self = [super init]))
{
self.lat = lat;
self.lon = lon;
self.optionalTitle = title;
self.optionalId = pinId;
self.title = title;
self.idOrUrl = idOrUrl;
}
return self;
}
- (void)dealloc
{
self.optionalTitle = nil;
self.optionalId = nil;
self.title = nil;
self.idOrUrl = nil;
[super dealloc];
}
@end
@ -108,9 +108,9 @@ static NSString * MWMUrlScheme = @"mapswithme://";
}
}
else if ([key isEqualToString:@"n"])
pin.optionalTitle = [[values objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
pin.title = [[values objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
else if ([key isEqualToString:@"id"])
pin.optionalId = [[values objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
pin.idOrUrl = [[values objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
else
NSLog(@"Unsupported url parameters: %@", values);
}
@ -132,9 +132,9 @@ static NSString * MWMUrlScheme = @"mapswithme://";
return [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[MWMUrlScheme stringByAppendingFormat:@"map?v=%d", MAPSWITHME_API_VERSION]]];
}
+ (BOOL) showLat:(double)lat lon:(double)lon title:(NSString *)optionalTitle id:(NSString *)optionalId
+ (BOOL) showLat:(double)lat lon:(double)lon title:(NSString *)title and:(NSString *)idOrUrl
{
MWMPin * pin = [[[MWMPin alloc] initWithLat:lat lon:lon title:optionalTitle id:optionalId] autorelease];
MWMPin * pin = [[[MWMPin alloc] initWithLat:lat lon:lon title:title and:idOrUrl] autorelease];
return [MWMApi showPin:pin];
}
@ -166,10 +166,10 @@ static NSString * MWMUrlScheme = @"mapswithme://";
[str appendFormat:@"ll=%f,%f&", point.lat, point.lon];
@autoreleasepool
{
if (point.optionalTitle)
[str appendFormat:@"n=%@&", [point.optionalTitle stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if (point.optionalId)
[str appendFormat:@"id=%@&", [point.optionalId stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if (point.title)
[str appendFormat:@"n=%@&", [point.title stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if (point.idOrUrl)
[str appendFormat:@"id=%@&", [point.idOrUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
}
@ -229,7 +229,7 @@ static NSString * mapsWithMeIsNotInstalledPage =
{
UIWebView * webView = [[[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
// check that we have Internet connection and display fresh online page if possible
if (gethostbyname("google.com"))
if (gethostbyname("mapswith.me"))
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://mapswith.me/api_mwm_not_installed"]]];
else
[webView loadHTMLString:mapsWithMeIsNotInstalledPage baseURL:[NSURL URLWithString:@"http://mapswith.me/"]];

View file

@ -43,7 +43,7 @@
MWMPin * pin = [MWMApi pinFromUrl:url];
if (pin)
{
size_t const cityId = [pin.optionalId integerValue];
size_t const cityId = [pin.idOrUrl integerValue];
// display selected page based on passed id
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{

View file

@ -52,7 +52,7 @@
pinId = [NSString stringWithFormat:@"http://en.wikipedia.org/wiki/%@", [self urlEncode:city->name]];
else
pinId = [NSString stringWithFormat:@"%ld", _cityIndex];
[MWMApi showLat:city->lat lon:city->lon title:city->name id:pinId];
[MWMApi showLat:city->lat lon:city->lon title:city->name and:pinId];
}
- (void)dealloc

View file

@ -44,7 +44,7 @@
{
NSString * pinId = [[[NSString alloc] initWithFormat:@"%ld", i] autorelease];
// Note that url is empty - it means "More details" button for a pin in MapsWithMe will lead back to this example app
MWMPin * pin = [[[MWMPin alloc] initWithLat:CAPITALS[i].lat lon:CAPITALS[i].lon title:CAPITALS[i].name id:pinId] autorelease];
MWMPin * pin = [[[MWMPin alloc] initWithLat:CAPITALS[i].lat lon:CAPITALS[i].lon title:CAPITALS[i].name and:pinId] autorelease];
[array addObject:pin];
}