diff --git a/objective-c/route_guide/ViewControllers.m b/objective-c/route_guide/ViewControllers.m index 0a38f269a45..797ef0a63c0 100644 --- a/objective-c/route_guide/ViewControllers.m +++ b/objective-c/route_guide/ViewControllers.m @@ -38,6 +38,9 @@ static NSString * const kHostAddress = @"http://localhost:50051"; #pragma mark 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. + @interface GetFeatureViewController : UIViewController @end @@ -48,13 +51,22 @@ static NSString * const kHostAddress = @"http://localhost:50051"; RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) { + if (response.name.length) { + NSLog(@"Found feature called %@ at %@.", response.name, response.location); + } else if (response) { + NSLog(@"Found no features at %@", response.location); + } else { + NSLog(@"RPC error: %@", error); + } + }; + RTGPoint *point = [RTGPoint message]; point.latitude = 409146138; point.longitude = -746188906; - [client getFeatureWithRequest:point handler:^(RTGFeature *response, NSError *error) { - NSLog(@"Response: %@", response); - }]; + [client getFeatureWithRequest:point handler:handler]; + [client getFeatureWithRequest:[RTGPoint message] handler:handler]; } @end