From 8676d22b3d9ee2c69b50b360fa07a57d3753e82f Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 28 Oct 2015 05:51:11 -0700 Subject: [PATCH 1/4] Fix RouteGuide example to use the last surface --- .../objective-c/route_guide/ViewControllers.m | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index cfc3338bcac..8332661d57f 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -36,7 +36,7 @@ #import #import -static NSString * const kHostAddress = @"http://localhost:50051"; +static NSString * const kHostAddress = @"localhost:50051"; // Category to override RTGPoint's description. @interface RTGPoint (Description) @@ -86,7 +86,10 @@ static NSString * const kHostAddress = @"http://localhost:50051"; - (void)viewDidLoad { [super viewDidLoad]; - RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + // This only needs to be done once per host, before creating service objects for that host. + [GRPCCall useInsecureConnectionsForHost:kHostAddress]; + + RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress]; void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) { if (response.name.length) { @@ -102,8 +105,8 @@ static NSString * const kHostAddress = @"http://localhost:50051"; point.latitude = 409146138; point.longitude = -746188906; - [client getFeatureWithRequest:point handler:handler]; - [client getFeatureWithRequest:[RTGPoint message] handler:handler]; + [service getFeatureWithRequest:point handler:handler]; + [service getFeatureWithRequest:[RTGPoint message] handler:handler]; } @end @@ -122,7 +125,7 @@ static NSString * const kHostAddress = @"http://localhost:50051"; - (void)viewDidLoad { [super viewDidLoad]; - RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress]; RTGRectangle *rectangle = [RTGRectangle message]; rectangle.lo.latitude = 405E6; @@ -131,8 +134,8 @@ static NSString * const kHostAddress = @"http://localhost:50051"; rectangle.hi.longitude = -745E6; NSLog(@"Looking for features between %@ and %@", rectangle.lo, rectangle.hi); - [client listFeaturesWithRequest:rectangle - eventHandler:^(BOOL done, RTGFeature *response, NSError *error) { + [service listFeaturesWithRequest:rectangle + eventHandler:^(BOOL done, RTGFeature *response, NSError *error) { if (response) { NSLog(@"Found feature at %@ called %@.", response.location, response.name); } else if (error) { @@ -171,9 +174,10 @@ static NSString * const kHostAddress = @"http://localhost:50051"; return location; }]; - RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress]; - [client recordRouteWithRequestsWriter:locations handler:^(RTGRouteSummary *response, NSError *error) { + [service recordRouteWithRequestsWriter:locations + handler:^(RTGRouteSummary *response, NSError *error) { if (response) { NSLog(@"Finished trip with %i points", response.pointCount); NSLog(@"Passed %i features", response.featureCount); @@ -210,10 +214,10 @@ static NSString * const kHostAddress = @"http://localhost:50051"; return note; }]; - RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress]; - [client routeChatWithRequestsWriter:notesWriter - eventHandler:^(BOOL done, RTGRouteNote *note, NSError *error) { + [service routeChatWithRequestsWriter:notesWriter + eventHandler:^(BOOL done, RTGRouteNote *note, NSError *error) { if (note) { NSLog(@"Got message %@ at %@", note.message, note.location); } else if (error) { From 7fb5b3c2a06d95f03a63548ed498348904c1e27e Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 28 Oct 2015 05:52:11 -0700 Subject: [PATCH 2/4] nit: Use appledoc-style documentation in the example --- .../objective-c/route_guide/ViewControllers.m | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index 8332661d57f..61367fdf85f 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -38,7 +38,7 @@ static NSString * const kHostAddress = @"localhost:50051"; -// Category to override RTGPoint's description. +/** Category to override RTGPoint's description. */ @interface RTGPoint (Description) - (NSString *)description; @end @@ -53,7 +53,7 @@ static NSString * const kHostAddress = @"localhost:50051"; } @end -// Category to give RTGRouteNote a convenience constructor. +/** Category to give RTGRouteNote a convenience constructor. */ @interface RTGRouteNote (Constructors) + (instancetype)noteWithMessage:(NSString *)message latitude:(float)latitude @@ -75,9 +75,10 @@ static NSString * const kHostAddress = @"localhost:50051"; #pragma mark Demo: Get Feature -// Run the getFeature demo. Calls getFeature with a point known to have a feature and a point known -// not to have a feature. - +/** + * Run the getFeature demo. Calls getFeature with a point known to have a feature and a point known + * not to have a feature. + */ @interface GetFeatureViewController : UIViewController @end @@ -114,9 +115,10 @@ static NSString * const kHostAddress = @"localhost:50051"; #pragma mark Demo: List Features -// Run the listFeatures demo. Calls listFeatures with a rectangle containing all of the features in -// the pre-generated database. Prints each response as it comes in. - +/** + * Run the listFeatures demo. Calls listFeatures with a rectangle containing all of the features in + * the pre-generated database. Prints each response as it comes in. + */ @interface ListFeaturesViewController : UIViewController @end @@ -149,10 +151,11 @@ static NSString * const kHostAddress = @"localhost:50051"; #pragma mark Demo: Record Route -// Run the recordRoute demo. Sends several randomly chosen points from the pre-generated feature -// database with a variable delay in between. Prints the statistics when they are sent from the -// server. - +/** + * Run the recordRoute demo. Sends several randomly chosen points from the pre-generated feature + * database with a variable delay in between. Prints the statistics when they are sent from the + * server. + */ @interface RecordRouteViewController : UIViewController @end @@ -194,9 +197,10 @@ static NSString * const kHostAddress = @"localhost:50051"; #pragma mark Demo: Route Chat -// Run the routeChat demo. Send some chat messages, and print any chat messages that are sent from -// the server. - +/** + * Run the routeChat demo. Send some chat messages, and print any chat messages that are sent from + * the server. + */ @interface RouteChatViewController : UIViewController @end From 6f7e26a5772bf363450aa32618dd20bcb4a07ae3 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 28 Oct 2015 06:07:05 -0700 Subject: [PATCH 3/4] pod install on route_guide project --- .../RouteGuideClient.xcodeproj/project.pbxproj | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/objective-c/route_guide/RouteGuideClient.xcodeproj/project.pbxproj b/examples/objective-c/route_guide/RouteGuideClient.xcodeproj/project.pbxproj index 6ab6b27a1b5..f99775562c0 100644 --- a/examples/objective-c/route_guide/RouteGuideClient.xcodeproj/project.pbxproj +++ b/examples/objective-c/route_guide/RouteGuideClient.xcodeproj/project.pbxproj @@ -121,6 +121,7 @@ 6325277A1B1D0395003073D9 /* Frameworks */, 6325277B1B1D0395003073D9 /* Resources */, FFE0BCF30339E7A50A989EAB /* Copy Pods Resources */, + B5388EC5A25E89021740B916 /* Embed Pods Frameworks */, ); buildRules = ( ); @@ -177,6 +178,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + B5388EC5A25E89021740B916 /* Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RouteGuideClient/Pods-RouteGuideClient-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; C6FC30AD2376EC04317237C5 /* Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; From 2f0d11bf2ad6dda052aa72b5991dc1634f12bce4 Mon Sep 17 00:00:00 2001 From: Jorge Canizales Date: Wed, 28 Oct 2015 06:07:26 -0700 Subject: [PATCH 4/4] Fix build breakage. --- examples/objective-c/route_guide/ViewControllers.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index 61367fdf85f..0b1a1cf4823 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -32,6 +32,7 @@ */ #import +#import #import #import #import @@ -90,7 +91,7 @@ static NSString * const kHostAddress = @"localhost:50051"; // This only needs to be done once per host, before creating service objects for that host. [GRPCCall useInsecureConnectionsForHost:kHostAddress]; - RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress]; + RTGRouteGuide *service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) { if (response.name.length) { @@ -127,7 +128,7 @@ static NSString * const kHostAddress = @"localhost:50051"; - (void)viewDidLoad { [super viewDidLoad]; - RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress]; + RTGRouteGuide *service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; RTGRectangle *rectangle = [RTGRectangle message]; rectangle.lo.latitude = 405E6; @@ -177,7 +178,7 @@ static NSString * const kHostAddress = @"localhost:50051"; return location; }]; - RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress]; + RTGRouteGuide *service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; [service recordRouteWithRequestsWriter:locations handler:^(RTGRouteSummary *response, NSError *error) { @@ -218,7 +219,7 @@ static NSString * const kHostAddress = @"localhost:50051"; return note; }]; - RTGRouteGuide *service = [RTGRouteGuide serviceWithHost:kHostAddress]; + RTGRouteGuide *service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; [service routeChatWithRequestsWriter:notesWriter eventHandler:^(BOOL done, RTGRouteNote *note, NSError *error) {