diff options
author | Muxi Yan <mxyan@google.com> | 2017-08-23 17:43:57 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2018-04-18 15:21:34 -0700 |
commit | e7aa6c77a13b83842562726076b733fd94dc7bd9 (patch) | |
tree | 2e0901772d939246b3d5a42898813695c696df4c /src | |
parent | 8cd9f914cc23acb9657c253df87f03fd81129203 (diff) |
Convert SwiftSample to Swift 3 style
Diffstat (limited to 'src')
-rw-r--r-- | src/objective-c/examples/SwiftSample/ViewController.swift | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/objective-c/examples/SwiftSample/ViewController.swift b/src/objective-c/examples/SwiftSample/ViewController.swift index 5931914b7b..873d0923b7 100644 --- a/src/objective-c/examples/SwiftSample/ViewController.swift +++ b/src/objective-c/examples/SwiftSample/ViewController.swift @@ -36,7 +36,7 @@ class ViewController: UIViewController { // Example gRPC call using a generated proto client library: let service = RMTTestService(host: RemoteHost) - service.unaryCallWithRequest(request) { response, error in + service.unaryCall(with: request) { response, error in if let response = response { NSLog("1. Finished successfully with response:\n\(response)") } else { @@ -48,7 +48,7 @@ class ViewController: UIViewController { // Same but manipulating headers: var RPC : GRPCProtoCall! // Needed to convince Swift to capture by reference (__block) - RPC = service.RPCToUnaryCallWithRequest(request) { response, error in + RPC = service.rpcToUnaryCall(with: request) { response, error in if let response = response { NSLog("2. Finished successfully with response:\n\(response)") } else { @@ -59,7 +59,7 @@ class ViewController: UIViewController { } // TODO(jcanizales): Revert to using subscript syntax once XCode 8 is released. - RPC.requestHeaders.setObject("My value", forKey: "My-Header") + RPC.requestHeaders.setObject("My value", forKey: "My-Header" as NSCopying) RPC.start() @@ -70,18 +70,18 @@ class ViewController: UIViewController { let requestsWriter = GRXWriter(value: request.data()) - let call = GRPCCall(host: RemoteHost, path: method.HTTPPath, requestsWriter: requestsWriter) + let call = GRPCCall(host: RemoteHost, path: method?.httpPath, requestsWriter: requestsWriter) - call.requestHeaders.setObject("My value", forKey: "My-Header") + call?.requestHeaders.setObject("My value", forKey: "My-Header" as NSCopying) - call.startWithWriteable(GRXWriteable { response, error in - if let response = response as? NSData { + call?.start(with: GRXWriteable { response, error in + if let response = response as? Data { NSLog("3. Received response:\n\(try! RMTSimpleResponse(data: response))") } else { NSLog("3. Finished with error: \(error!)") } - NSLog("3. Response headers: \(call.responseHeaders)") - NSLog("3. Response trailers: \(call.responseTrailers)") + NSLog("3. Response headers: \(call?.responseHeaders)") + NSLog("3. Response trailers: \(call?.responseTrailers)") }) } } |