diff options
author | Jorge Canizales <jcanizales@google.com> | 2015-06-04 23:06:13 -0700 |
---|---|---|
committer | Jorge Canizales <jcanizales@google.com> | 2015-06-05 17:49:13 -0700 |
commit | 4694cdb470f67e9fa70b194c3a2894ba4cf68f7e (patch) | |
tree | 5372e7ddb51d4ed841233f34988c4ba509671239 | |
parent | 3aed717df1678e3e8f42abd006465d2378a7d47c (diff) |
ListFeatures demo
-rw-r--r-- | objective-c/route_guide/ViewControllers.m | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/objective-c/route_guide/ViewControllers.m b/objective-c/route_guide/ViewControllers.m index 797ef0a63c..6a1e8b9db4 100644 --- a/objective-c/route_guide/ViewControllers.m +++ b/objective-c/route_guide/ViewControllers.m @@ -73,6 +73,9 @@ static NSString * const kHostAddress = @"http://localhost:50051"; #pragma mark 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. + @interface ListFeaturesViewController : UIViewController @end @@ -80,7 +83,23 @@ static NSString * const kHostAddress = @"http://localhost:50051"; - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + + RTGRouteGuide *client = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + + RTGRectangle *rectangle = [RTGRectangle message]; + rectangle.lo.latitude = 40E7; + rectangle.lo.longitude = -75E7; + rectangle.hi.latitude = 42E7; + rectangle.hi.longitude = -73E7; + + NSLog(@"Looking for features between 40, -75 and 42, -73"); + [client listFeaturesWithRequest:rectangle handler:^(BOOL done, RTGFeature *response, NSError *error) { + if (response) { + NSLog(@"Found feature called %@ at %@.", response.name, response.location); + } else if (error) { + NSLog(@"RPC error: %@", error); + } + }]; } @end |