From a7cc90055e91b1bda2e916c5884b5305c7f73b53 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Thu, 16 Jun 2016 09:59:51 -0700 Subject: [PATCH 1/6] Modified route_guide sample app to show RPC log Modified the screens to show meaningful information about RPC progress. When you click on each tab the screen now shows log messages that previously only went to the debug console. --- .../Misc/Base.lproj/Main.storyboard | 108 ++++++++++-------- .../objective-c/route_guide/ViewControllers.m | 41 +++++++ 2 files changed, 102 insertions(+), 47 deletions(-) diff --git a/examples/objective-c/route_guide/Misc/Base.lproj/Main.storyboard b/examples/objective-c/route_guide/Misc/Base.lproj/Main.storyboard index 9bf9498d62c..306320f7d89 100644 --- a/examples/objective-c/route_guide/Misc/Base.lproj/Main.storyboard +++ b/examples/objective-c/route_guide/Misc/Base.lproj/Main.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -16,33 +17,35 @@ - - - - - + + + + - + @@ -56,29 +59,35 @@ - + + + - - - - + + + + + @@ -117,29 +126,32 @@ - - - - - + + + + + @@ -157,29 +169,31 @@ - - - - - + + + + diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index e32978240b6..b916a4ee0c4 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -83,6 +83,7 @@ static NSString * const kHostAddress = @"localhost:50051"; @interface GetFeatureViewController : UIViewController { RTGRouteGuide *service; } +@property (weak, nonatomic) IBOutlet UILabel *output_label; @end @implementation GetFeatureViewController @@ -90,10 +91,16 @@ static NSString * const kHostAddress = @"localhost:50051"; - (void)execRequest { void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) { if (response.name.length) { + NSString *str =[NSString stringWithFormat:@"%@\nFound feature called %@ at %@.", self.output_label.text, response.location, response.name]; + self.output_label.text = str; NSLog(@"Found feature called %@ at %@.", response.name, response.location); } else if (response) { + NSString *str =[NSString stringWithFormat:@"%@\nFound no features at %@", self.output_label.text,response.location]; + self.output_label.text = str; NSLog(@"Found no features at %@", response.location); } else { + NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.output_label.text, error]; + self.output_label.text = str; NSLog(@"RPC error: %@", error); } }; @@ -116,6 +123,9 @@ static NSString * const kHostAddress = @"localhost:50051"; } - (void)viewDidAppear:(BOOL)animated { + self.output_label.text = @"RPC log:"; + self.output_label.numberOfLines = 0; + self.output_label.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; [self execRequest]; } @@ -131,6 +141,7 @@ static NSString * const kHostAddress = @"localhost:50051"; @interface ListFeaturesViewController : UIViewController { RTGRouteGuide *service; } +@property (weak, nonatomic) IBOutlet UILabel *output_label; @end @@ -147,8 +158,12 @@ static NSString * const kHostAddress = @"localhost:50051"; [service listFeaturesWithRequest:rectangle eventHandler:^(BOOL done, RTGFeature *response, NSError *error) { if (response) { + NSString *str =[NSString stringWithFormat:@"%@\nFound feature at %@ called %@.", self.output_label.text, response.location, response.name]; + self.output_label.text = str; NSLog(@"Found feature at %@ called %@.", response.location, response.name); } else if (error) { + NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.output_label.text, error]; + self.output_label.text = str; NSLog(@"RPC error: %@", error); } }]; @@ -161,6 +176,9 @@ static NSString * const kHostAddress = @"localhost:50051"; } - (void)viewDidAppear:(BOOL)animated { + self.output_label.text = @"RPC log:"; + self.output_label.numberOfLines = 0; + self.output_label.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; [self execRequest]; } @@ -177,6 +195,7 @@ static NSString * const kHostAddress = @"localhost:50051"; @interface RecordRouteViewController : UIViewController { RTGRouteGuide *service; } +@property (weak, nonatomic) IBOutlet UILabel *output_label; @end @@ -192,6 +211,8 @@ static NSString * const kHostAddress = @"localhost:50051"; RTGPoint *location = [RTGPoint message]; location.longitude = [((NSNumber *) feature[@"location"][@"longitude"]) intValue]; location.latitude = [((NSNumber *) feature[@"location"][@"latitude"]) intValue]; + NSString *str =[NSString stringWithFormat:@"%@\nVisiting point %@", self.output_label.text, location]; + self.output_label.text = str; NSLog(@"Visiting point %@", location); return location; }]; @@ -199,11 +220,19 @@ static NSString * const kHostAddress = @"localhost:50051"; [service recordRouteWithRequestsWriter:locations handler:^(RTGRouteSummary *response, NSError *error) { if (response) { + NSString *str =[NSString stringWithFormat: + @"%@\nFinished trip with %i points\nPassed %i features\n" + "Travelled %i meters\nIt took %i seconds", + self.output_label.text, response.pointCount, response.featureCount, + response.distance, response.elapsedTime]; + self.output_label.text = str; NSLog(@"Finished trip with %i points", response.pointCount); NSLog(@"Passed %i features", response.featureCount); NSLog(@"Travelled %i meters", response.distance); NSLog(@"It took %i seconds", response.elapsedTime); } else { + NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.output_label.text, error]; + self.output_label.text = str; NSLog(@"RPC error: %@", error); } }]; @@ -216,6 +245,9 @@ static NSString * const kHostAddress = @"localhost:50051"; } - (void)viewDidAppear:(BOOL)animated { + self.output_label.text = @"RPC log:"; + self.output_label.numberOfLines = 0; + self.output_label.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; [self execRequest]; } @@ -231,6 +263,7 @@ static NSString * const kHostAddress = @"localhost:50051"; @interface RouteChatViewController : UIViewController { RTGRouteGuide *service; } +@property (weak, nonatomic) IBOutlet UILabel *output_label; @end @@ -249,8 +282,13 @@ static NSString * const kHostAddress = @"localhost:50051"; [service routeChatWithRequestsWriter:notesWriter eventHandler:^(BOOL done, RTGRouteNote *note, NSError *error) { if (note) { + NSString *str =[NSString stringWithFormat:@"%@\nGot message %@ at %@", + self.output_label.text, note.message, note.location]; + self.output_label.text = str; NSLog(@"Got message %@ at %@", note.message, note.location); } else if (error) { + NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.output_label.text, error]; + self.output_label.text = str; NSLog(@"RPC error: %@", error); } if (done) { @@ -266,6 +304,9 @@ static NSString * const kHostAddress = @"localhost:50051"; } - (void)viewDidAppear:(BOOL)animated { + self.output_label.text = @"RPC log:"; + self.output_label.numberOfLines = 0; + self.output_label.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; [self execRequest]; } From 3eba9075ef612f83c363868c24d106580ab25223 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Thu, 16 Jun 2016 10:15:32 -0700 Subject: [PATCH 2/6] using camelCase for output_label now --- .../Misc/Base.lproj/Main.storyboard | 8 +- .../objective-c/route_guide/ViewControllers.m | 74 +++++++++---------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/objective-c/route_guide/Misc/Base.lproj/Main.storyboard b/examples/objective-c/route_guide/Misc/Base.lproj/Main.storyboard index 306320f7d89..5ca9f4642b9 100644 --- a/examples/objective-c/route_guide/Misc/Base.lproj/Main.storyboard +++ b/examples/objective-c/route_guide/Misc/Base.lproj/Main.storyboard @@ -40,7 +40,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -150,7 +150,7 @@ - + @@ -192,7 +192,7 @@ - + diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index b916a4ee0c4..1e84c334728 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -37,7 +37,7 @@ #import #import -static NSString * const kHostAddress = @"localhost:50051"; +static NSString * const kHostAddress = @"192.168.1.120:50051"; /** Category to override RTGPoint's description. */ @interface RTGPoint (Description) @@ -83,7 +83,7 @@ static NSString * const kHostAddress = @"localhost:50051"; @interface GetFeatureViewController : UIViewController { RTGRouteGuide *service; } -@property (weak, nonatomic) IBOutlet UILabel *output_label; +@property (weak, nonatomic) IBOutlet UILabel *outputLabel; @end @implementation GetFeatureViewController @@ -91,16 +91,16 @@ static NSString * const kHostAddress = @"localhost:50051"; - (void)execRequest { void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) { if (response.name.length) { - NSString *str =[NSString stringWithFormat:@"%@\nFound feature called %@ at %@.", self.output_label.text, response.location, response.name]; - self.output_label.text = str; + NSString *str =[NSString stringWithFormat:@"%@\nFound feature called %@ at %@.", self.outputLabel.text, response.location, response.name]; + self.outputLabel.text = str; NSLog(@"Found feature called %@ at %@.", response.name, response.location); } else if (response) { - NSString *str =[NSString stringWithFormat:@"%@\nFound no features at %@", self.output_label.text,response.location]; - self.output_label.text = str; + NSString *str =[NSString stringWithFormat:@"%@\nFound no features at %@", self.outputLabel.text,response.location]; + self.outputLabel.text = str; NSLog(@"Found no features at %@", response.location); } else { - NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.output_label.text, error]; - self.output_label.text = str; + NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.outputLabel.text, error]; + self.outputLabel.text = str; NSLog(@"RPC error: %@", error); } }; @@ -123,9 +123,9 @@ static NSString * const kHostAddress = @"localhost:50051"; } - (void)viewDidAppear:(BOOL)animated { - self.output_label.text = @"RPC log:"; - self.output_label.numberOfLines = 0; - self.output_label.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; + self.outputLabel.text = @"RPC log:"; + self.outputLabel.numberOfLines = 0; + self.outputLabel.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; [self execRequest]; } @@ -141,7 +141,7 @@ static NSString * const kHostAddress = @"localhost:50051"; @interface ListFeaturesViewController : UIViewController { RTGRouteGuide *service; } -@property (weak, nonatomic) IBOutlet UILabel *output_label; +@property (weak, nonatomic) IBOutlet UILabel *outputLabel; @end @@ -158,12 +158,12 @@ static NSString * const kHostAddress = @"localhost:50051"; [service listFeaturesWithRequest:rectangle eventHandler:^(BOOL done, RTGFeature *response, NSError *error) { if (response) { - NSString *str =[NSString stringWithFormat:@"%@\nFound feature at %@ called %@.", self.output_label.text, response.location, response.name]; - self.output_label.text = str; + NSString *str =[NSString stringWithFormat:@"%@\nFound feature at %@ called %@.", self.outputLabel.text, response.location, response.name]; + self.outputLabel.text = str; NSLog(@"Found feature at %@ called %@.", response.location, response.name); } else if (error) { - NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.output_label.text, error]; - self.output_label.text = str; + NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.outputLabel.text, error]; + self.outputLabel.text = str; NSLog(@"RPC error: %@", error); } }]; @@ -176,9 +176,9 @@ static NSString * const kHostAddress = @"localhost:50051"; } - (void)viewDidAppear:(BOOL)animated { - self.output_label.text = @"RPC log:"; - self.output_label.numberOfLines = 0; - self.output_label.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; + self.outputLabel.text = @"RPC log:"; + self.outputLabel.numberOfLines = 0; + self.outputLabel.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; [self execRequest]; } @@ -195,7 +195,7 @@ static NSString * const kHostAddress = @"localhost:50051"; @interface RecordRouteViewController : UIViewController { RTGRouteGuide *service; } -@property (weak, nonatomic) IBOutlet UILabel *output_label; +@property (weak, nonatomic) IBOutlet UILabel *outputLabel; @end @@ -211,8 +211,8 @@ static NSString * const kHostAddress = @"localhost:50051"; RTGPoint *location = [RTGPoint message]; location.longitude = [((NSNumber *) feature[@"location"][@"longitude"]) intValue]; location.latitude = [((NSNumber *) feature[@"location"][@"latitude"]) intValue]; - NSString *str =[NSString stringWithFormat:@"%@\nVisiting point %@", self.output_label.text, location]; - self.output_label.text = str; + NSString *str =[NSString stringWithFormat:@"%@\nVisiting point %@", self.outputLabel.text, location]; + self.outputLabel.text = str; NSLog(@"Visiting point %@", location); return location; }]; @@ -223,16 +223,16 @@ static NSString * const kHostAddress = @"localhost:50051"; NSString *str =[NSString stringWithFormat: @"%@\nFinished trip with %i points\nPassed %i features\n" "Travelled %i meters\nIt took %i seconds", - self.output_label.text, response.pointCount, response.featureCount, + self.outputLabel.text, response.pointCount, response.featureCount, response.distance, response.elapsedTime]; - self.output_label.text = str; + self.outputLabel.text = str; NSLog(@"Finished trip with %i points", response.pointCount); NSLog(@"Passed %i features", response.featureCount); NSLog(@"Travelled %i meters", response.distance); NSLog(@"It took %i seconds", response.elapsedTime); } else { - NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.output_label.text, error]; - self.output_label.text = str; + NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.outputLabel.text, error]; + self.outputLabel.text = str; NSLog(@"RPC error: %@", error); } }]; @@ -245,9 +245,9 @@ static NSString * const kHostAddress = @"localhost:50051"; } - (void)viewDidAppear:(BOOL)animated { - self.output_label.text = @"RPC log:"; - self.output_label.numberOfLines = 0; - self.output_label.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; + self.outputLabel.text = @"RPC log:"; + self.outputLabel.numberOfLines = 0; + self.outputLabel.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; [self execRequest]; } @@ -263,7 +263,7 @@ static NSString * const kHostAddress = @"localhost:50051"; @interface RouteChatViewController : UIViewController { RTGRouteGuide *service; } -@property (weak, nonatomic) IBOutlet UILabel *output_label; +@property (weak, nonatomic) IBOutlet UILabel *outputLabel; @end @@ -283,12 +283,12 @@ static NSString * const kHostAddress = @"localhost:50051"; eventHandler:^(BOOL done, RTGRouteNote *note, NSError *error) { if (note) { NSString *str =[NSString stringWithFormat:@"%@\nGot message %@ at %@", - self.output_label.text, note.message, note.location]; - self.output_label.text = str; + self.outputLabel.text, note.message, note.location]; + self.outputLabel.text = str; NSLog(@"Got message %@ at %@", note.message, note.location); } else if (error) { - NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.output_label.text, error]; - self.output_label.text = str; + NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.outputLabel.text, error]; + self.outputLabel.text = str; NSLog(@"RPC error: %@", error); } if (done) { @@ -304,9 +304,9 @@ static NSString * const kHostAddress = @"localhost:50051"; } - (void)viewDidAppear:(BOOL)animated { - self.output_label.text = @"RPC log:"; - self.output_label.numberOfLines = 0; - self.output_label.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; + self.outputLabel.text = @"RPC log:"; + self.outputLabel.numberOfLines = 0; + self.outputLabel.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; [self execRequest]; } From 4412c85a1079f2ac55a9a27641076ca34c1a2c62 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Thu, 16 Jun 2016 10:37:51 -0700 Subject: [PATCH 3/6] crud removal --- examples/objective-c/route_guide/ViewControllers.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index 1e84c334728..5fd411e3ba6 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -37,7 +37,7 @@ #import #import -static NSString * const kHostAddress = @"192.168.1.120:50051"; +static NSString * const kHostAddress = @"localhost:50051"; /** Category to override RTGPoint's description. */ @interface RTGPoint (Description) From dde4fc66fb55291434a017c667d6a961332801e6 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Thu, 23 Jun 2016 10:35:19 -0700 Subject: [PATCH 4/6] changed service to _service, and added a TODO TODO for removing boilerplate code --- .../objective-c/route_guide/ViewControllers.m | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index 5fd411e3ba6..a5c03e9cfca 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -81,7 +81,7 @@ static NSString * const kHostAddress = @"localhost:50051"; * not to have a feature. */ @interface GetFeatureViewController : UIViewController { - RTGRouteGuide *service; + RTGRouteGuide *_service; } @property (weak, nonatomic) IBOutlet UILabel *outputLabel; @end @@ -90,6 +90,7 @@ static NSString * const kHostAddress = @"localhost:50051"; - (void)execRequest { void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) { + // TODO(makdharma): Remove boilerplate by consolidating into one log function. if (response.name.length) { NSString *str =[NSString stringWithFormat:@"%@\nFound feature called %@ at %@.", self.outputLabel.text, response.location, response.name]; self.outputLabel.text = str; @@ -109,8 +110,8 @@ static NSString * const kHostAddress = @"localhost:50051"; point.latitude = 409146138; point.longitude = -746188906; - [service getFeatureWithRequest:point handler:handler]; - [service getFeatureWithRequest:[RTGPoint message] handler:handler]; + [_service getFeatureWithRequest:point handler:handler]; + [_service getFeatureWithRequest:[RTGPoint message] handler:handler]; } - (void)viewDidLoad { @@ -119,7 +120,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]; - service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + _service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; } - (void)viewDidAppear:(BOOL)animated { @@ -139,7 +140,7 @@ static NSString * const kHostAddress = @"localhost:50051"; * the pre-generated database. Prints each response as it comes in. */ @interface ListFeaturesViewController : UIViewController { - RTGRouteGuide *service; + RTGRouteGuide *_service; } @property (weak, nonatomic) IBOutlet UILabel *outputLabel; @@ -155,7 +156,7 @@ static NSString * const kHostAddress = @"localhost:50051"; rectangle.hi.longitude = -745E6; NSLog(@"Looking for features between %@ and %@", rectangle.lo, rectangle.hi); - [service listFeaturesWithRequest:rectangle + [_service listFeaturesWithRequest:rectangle eventHandler:^(BOOL done, RTGFeature *response, NSError *error) { if (response) { NSString *str =[NSString stringWithFormat:@"%@\nFound feature at %@ called %@.", self.outputLabel.text, response.location, response.name]; @@ -172,7 +173,7 @@ static NSString * const kHostAddress = @"localhost:50051"; - (void)viewDidLoad { [super viewDidLoad]; - service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + _service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; } - (void)viewDidAppear:(BOOL)animated { @@ -193,7 +194,7 @@ static NSString * const kHostAddress = @"localhost:50051"; * server. */ @interface RecordRouteViewController : UIViewController { - RTGRouteGuide *service; + RTGRouteGuide *_service; } @property (weak, nonatomic) IBOutlet UILabel *outputLabel; @@ -217,7 +218,7 @@ static NSString * const kHostAddress = @"localhost:50051"; return location; }]; - [service recordRouteWithRequestsWriter:locations + [_service recordRouteWithRequestsWriter:locations handler:^(RTGRouteSummary *response, NSError *error) { if (response) { NSString *str =[NSString stringWithFormat: @@ -241,7 +242,7 @@ static NSString * const kHostAddress = @"localhost:50051"; - (void)viewDidLoad { [super viewDidLoad]; - service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + _service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; } - (void)viewDidAppear:(BOOL)animated { @@ -261,7 +262,7 @@ static NSString * const kHostAddress = @"localhost:50051"; * the server. */ @interface RouteChatViewController : UIViewController { - RTGRouteGuide *service; + RTGRouteGuide *_service; } @property (weak, nonatomic) IBOutlet UILabel *outputLabel; @@ -279,7 +280,7 @@ static NSString * const kHostAddress = @"localhost:50051"; return note; }]; - [service routeChatWithRequestsWriter:notesWriter + [_service routeChatWithRequestsWriter:notesWriter eventHandler:^(BOOL done, RTGRouteNote *note, NSError *error) { if (note) { NSString *str =[NSString stringWithFormat:@"%@\nGot message %@ at %@", @@ -300,7 +301,7 @@ static NSString * const kHostAddress = @"localhost:50051"; - (void)viewDidLoad { [super viewDidLoad]; - service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; + _service = [[RTGRouteGuide alloc] initWithHost:kHostAddress]; } - (void)viewDidAppear:(BOOL)animated { From abd285aed813ff55329e76a9dc19eb3a1bc86166 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Thu, 23 Jun 2016 13:30:19 -0700 Subject: [PATCH 5/6] Added missing todo and moved _service To Implementation --- .../objective-c/route_guide/ViewControllers.m | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index a5c03e9cfca..26ca9d6220b 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -80,13 +80,14 @@ static NSString * const kHostAddress = @"localhost:50051"; * 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 { - RTGRouteGuide *_service; -} +@interface GetFeatureViewController : UIViewController + @property (weak, nonatomic) IBOutlet UILabel *outputLabel; + @end @implementation GetFeatureViewController +RTGRouteGuide *_service; - (void)execRequest { void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) { @@ -139,14 +140,14 @@ static NSString * const kHostAddress = @"localhost:50051"; * 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 { - RTGRouteGuide *_service; -} +@interface ListFeaturesViewController : UIViewController + @property (weak, nonatomic) IBOutlet UILabel *outputLabel; @end @implementation ListFeaturesViewController +RTGRouteGuide *_service; - (void)execRequest { RTGRectangle *rectangle = [RTGRectangle message]; @@ -193,14 +194,14 @@ static NSString * const kHostAddress = @"localhost:50051"; * database with a variable delay in between. Prints the statistics when they are sent from the * server. */ -@interface RecordRouteViewController : UIViewController { - RTGRouteGuide *_service; -} +@interface RecordRouteViewController : UIViewController + @property (weak, nonatomic) IBOutlet UILabel *outputLabel; @end @implementation RecordRouteViewController +RTGRouteGuide *_service; - (void)execRequest { NSString *dataBasePath = [NSBundle.mainBundle pathForResource:@"route_guide_db" @@ -233,7 +234,7 @@ static NSString * const kHostAddress = @"localhost:50051"; NSLog(@"It took %i seconds", response.elapsedTime); } else { NSString *str =[NSString stringWithFormat:@"%@\nRPC error: %@", self.outputLabel.text, error]; - self.outputLabel.text = str; + self.outputLabel.text = str; NSLog(@"RPC error: %@", error); } }]; @@ -261,14 +262,14 @@ static NSString * const kHostAddress = @"localhost:50051"; * Run the routeChat demo. Send some chat messages, and print any chat messages that are sent from * the server. */ -@interface RouteChatViewController : UIViewController { - RTGRouteGuide *_service; -} +@interface RouteChatViewController : UIViewController + @property (weak, nonatomic) IBOutlet UILabel *outputLabel; @end @implementation RouteChatViewController +RTGRouteGuide *_service; - (void)execRequest { NSArray *notes = @[[RTGRouteNote noteWithMessage:@"First message" latitude:0 longitude:0], @@ -305,6 +306,7 @@ static NSString * const kHostAddress = @"localhost:50051"; } - (void)viewDidAppear:(BOOL)animated { + // TODO(makarandd): Set these properties through UI builder self.outputLabel.text = @"RPC log:"; self.outputLabel.numberOfLines = 0; self.outputLabel.font = [UIFont fontWithName:@"Helvetica Neue" size:8.0]; From 5a3c6389edeaf19e7e0f0a6c0771c7548f0e0997 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Thu, 23 Jun 2016 14:02:33 -0700 Subject: [PATCH 6/6] Added braces around _service --- .../objective-c/route_guide/ViewControllers.m | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/objective-c/route_guide/ViewControllers.m b/examples/objective-c/route_guide/ViewControllers.m index 26ca9d6220b..b2f99c437e7 100644 --- a/examples/objective-c/route_guide/ViewControllers.m +++ b/examples/objective-c/route_guide/ViewControllers.m @@ -86,8 +86,9 @@ static NSString * const kHostAddress = @"localhost:50051"; @end -@implementation GetFeatureViewController -RTGRouteGuide *_service; +@implementation GetFeatureViewController { + RTGRouteGuide *_service; +} - (void)execRequest { void (^handler)(RTGFeature *response, NSError *error) = ^(RTGFeature *response, NSError *error) { @@ -146,8 +147,9 @@ RTGRouteGuide *_service; @end -@implementation ListFeaturesViewController -RTGRouteGuide *_service; +@implementation ListFeaturesViewController { + RTGRouteGuide *_service; +} - (void)execRequest { RTGRectangle *rectangle = [RTGRectangle message]; @@ -200,8 +202,9 @@ RTGRouteGuide *_service; @end -@implementation RecordRouteViewController -RTGRouteGuide *_service; +@implementation RecordRouteViewController { + RTGRouteGuide *_service; +} - (void)execRequest { NSString *dataBasePath = [NSBundle.mainBundle pathForResource:@"route_guide_db" @@ -268,8 +271,9 @@ RTGRouteGuide *_service; @end -@implementation RouteChatViewController -RTGRouteGuide *_service; +@implementation RouteChatViewController { + RTGRouteGuide *_service; +} - (void)execRequest { NSArray *notes = @[[RTGRouteNote noteWithMessage:@"First message" latitude:0 longitude:0],