Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
dde4fc66
Commit
dde4fc66
authored
8 years ago
by
Makarand Dharmapurikar
Browse files
Options
Downloads
Patches
Plain Diff
changed service to _service, and added a TODO
TODO for removing boilerplate code
parent
4412c85a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/objective-c/route_guide/ViewControllers.m
+14
-13
14 additions, 13 deletions
examples/objective-c/route_guide/ViewControllers.m
with
14 additions
and
13 deletions
examples/objective-c/route_guide/ViewControllers.m
+
14
−
13
View file @
dde4fc66
...
@@ -81,7 +81,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -81,7 +81,7 @@ static NSString * const kHostAddress = @"localhost:50051";
* not to have a feature.
* not to have a feature.
*/
*/
@interface
GetFeatureViewController
:
UIViewController
{
@interface
GetFeatureViewController
:
UIViewController
{
RTGRouteGuide
*
service
;
RTGRouteGuide
*
_
service
;
}
}
@property
(
weak
,
nonatomic
)
IBOutlet
UILabel
*
outputLabel
;
@property
(
weak
,
nonatomic
)
IBOutlet
UILabel
*
outputLabel
;
@end
@end
...
@@ -90,6 +90,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -90,6 +90,7 @@ static NSString * const kHostAddress = @"localhost:50051";
-
(
void
)
execRequest
{
-
(
void
)
execRequest
{
void
(
^
handler
)(
RTGFeature
*
response
,
NSError
*
error
)
=
^
(
RTGFeature
*
response
,
NSError
*
error
)
{
void
(
^
handler
)(
RTGFeature
*
response
,
NSError
*
error
)
=
^
(
RTGFeature
*
response
,
NSError
*
error
)
{
// TODO(makdharma): Remove boilerplate by consolidating into one log function.
if
(
response
.
name
.
length
)
{
if
(
response
.
name
.
length
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%@
\n
Found feature called %@ at %@."
,
self
.
outputLabel
.
text
,
response
.
location
,
response
.
name
];
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%@
\n
Found feature called %@ at %@."
,
self
.
outputLabel
.
text
,
response
.
location
,
response
.
name
];
self
.
outputLabel
.
text
=
str
;
self
.
outputLabel
.
text
=
str
;
...
@@ -109,8 +110,8 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -109,8 +110,8 @@ static NSString * const kHostAddress = @"localhost:50051";
point
.
latitude
=
409146138
;
point
.
latitude
=
409146138
;
point
.
longitude
=
-
746188906
;
point
.
longitude
=
-
746188906
;
[
service
getFeatureWithRequest
:
point
handler
:
handler
];
[
_
service
getFeatureWithRequest
:
point
handler
:
handler
];
[
service
getFeatureWithRequest
:[
RTGPoint
message
]
handler
:
handler
];
[
_
service
getFeatureWithRequest
:[
RTGPoint
message
]
handler
:
handler
];
}
}
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
...
@@ -119,7 +120,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -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.
// This only needs to be done once per host, before creating service objects for that host.
[
GRPCCall
useInsecureConnectionsForHost
:
kHostAddress
];
[
GRPCCall
useInsecureConnectionsForHost
:
kHostAddress
];
service
=
[[
RTGRouteGuide
alloc
]
initWithHost
:
kHostAddress
];
_
service
=
[[
RTGRouteGuide
alloc
]
initWithHost
:
kHostAddress
];
}
}
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
...
@@ -139,7 +140,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -139,7 +140,7 @@ static NSString * const kHostAddress = @"localhost:50051";
* the pre-generated database. Prints each response as it comes in.
* the pre-generated database. Prints each response as it comes in.
*/
*/
@interface
ListFeaturesViewController
:
UIViewController
{
@interface
ListFeaturesViewController
:
UIViewController
{
RTGRouteGuide
*
service
;
RTGRouteGuide
*
_
service
;
}
}
@property
(
weak
,
nonatomic
)
IBOutlet
UILabel
*
outputLabel
;
@property
(
weak
,
nonatomic
)
IBOutlet
UILabel
*
outputLabel
;
...
@@ -155,7 +156,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -155,7 +156,7 @@ static NSString * const kHostAddress = @"localhost:50051";
rectangle
.
hi
.
longitude
=
-
745E6
;
rectangle
.
hi
.
longitude
=
-
745E6
;
NSLog
(
@"Looking for features between %@ and %@"
,
rectangle
.
lo
,
rectangle
.
hi
);
NSLog
(
@"Looking for features between %@ and %@"
,
rectangle
.
lo
,
rectangle
.
hi
);
[
service
listFeaturesWithRequest
:
rectangle
[
_
service
listFeaturesWithRequest
:
rectangle
eventHandler:
^
(
BOOL
done
,
RTGFeature
*
response
,
NSError
*
error
)
{
eventHandler:
^
(
BOOL
done
,
RTGFeature
*
response
,
NSError
*
error
)
{
if
(
response
)
{
if
(
response
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%@
\n
Found feature at %@ called %@."
,
self
.
outputLabel
.
text
,
response
.
location
,
response
.
name
];
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%@
\n
Found feature at %@ called %@."
,
self
.
outputLabel
.
text
,
response
.
location
,
response
.
name
];
...
@@ -172,7 +173,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -172,7 +173,7 @@ static NSString * const kHostAddress = @"localhost:50051";
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
super
viewDidLoad
];
service
=
[[
RTGRouteGuide
alloc
]
initWithHost
:
kHostAddress
];
_
service
=
[[
RTGRouteGuide
alloc
]
initWithHost
:
kHostAddress
];
}
}
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
...
@@ -193,7 +194,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -193,7 +194,7 @@ static NSString * const kHostAddress = @"localhost:50051";
* server.
* server.
*/
*/
@interface
RecordRouteViewController
:
UIViewController
{
@interface
RecordRouteViewController
:
UIViewController
{
RTGRouteGuide
*
service
;
RTGRouteGuide
*
_
service
;
}
}
@property
(
weak
,
nonatomic
)
IBOutlet
UILabel
*
outputLabel
;
@property
(
weak
,
nonatomic
)
IBOutlet
UILabel
*
outputLabel
;
...
@@ -217,7 +218,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -217,7 +218,7 @@ static NSString * const kHostAddress = @"localhost:50051";
return
location
;
return
location
;
}];
}];
[
service
recordRouteWithRequestsWriter
:
locations
[
_
service
recordRouteWithRequestsWriter
:
locations
handler:
^
(
RTGRouteSummary
*
response
,
NSError
*
error
)
{
handler:
^
(
RTGRouteSummary
*
response
,
NSError
*
error
)
{
if
(
response
)
{
if
(
response
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
NSString
*
str
=
[
NSString
stringWithFormat
:
...
@@ -241,7 +242,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -241,7 +242,7 @@ static NSString * const kHostAddress = @"localhost:50051";
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
super
viewDidLoad
];
service
=
[[
RTGRouteGuide
alloc
]
initWithHost
:
kHostAddress
];
_
service
=
[[
RTGRouteGuide
alloc
]
initWithHost
:
kHostAddress
];
}
}
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
...
@@ -261,7 +262,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -261,7 +262,7 @@ static NSString * const kHostAddress = @"localhost:50051";
* the server.
* the server.
*/
*/
@interface
RouteChatViewController
:
UIViewController
{
@interface
RouteChatViewController
:
UIViewController
{
RTGRouteGuide
*
service
;
RTGRouteGuide
*
_
service
;
}
}
@property
(
weak
,
nonatomic
)
IBOutlet
UILabel
*
outputLabel
;
@property
(
weak
,
nonatomic
)
IBOutlet
UILabel
*
outputLabel
;
...
@@ -279,7 +280,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -279,7 +280,7 @@ static NSString * const kHostAddress = @"localhost:50051";
return
note
;
return
note
;
}];
}];
[
service
routeChatWithRequestsWriter
:
notesWriter
[
_
service
routeChatWithRequestsWriter
:
notesWriter
eventHandler:
^
(
BOOL
done
,
RTGRouteNote
*
note
,
NSError
*
error
)
{
eventHandler:
^
(
BOOL
done
,
RTGRouteNote
*
note
,
NSError
*
error
)
{
if
(
note
)
{
if
(
note
)
{
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%@
\n
Got message %@ at %@"
,
NSString
*
str
=
[
NSString
stringWithFormat
:
@"%@
\n
Got message %@ at %@"
,
...
@@ -300,7 +301,7 @@ static NSString * const kHostAddress = @"localhost:50051";
...
@@ -300,7 +301,7 @@ static NSString * const kHostAddress = @"localhost:50051";
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
super
viewDidLoad
];
service
=
[[
RTGRouteGuide
alloc
]
initWithHost
:
kHostAddress
];
_
service
=
[[
RTGRouteGuide
alloc
]
initWithHost
:
kHostAddress
];
}
}
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment