aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-08-31 18:05:56 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-08-31 19:18:20 -0700
commit875d1d15c85358c735d449c347d1e6b3c015e594 (patch)
tree2c8a05dfed0af7456ac08c35c77fb4908af461fa /src
parent587c2550dd83b92ef454f4f7f5f3ad44f9934e7d (diff)
Add Swift example with non-generated code :D
Diffstat (limited to 'src')
-rw-r--r--src/objective-c/examples/SwiftSample/Bridging-Header.h5
-rw-r--r--src/objective-c/examples/SwiftSample/ViewController.swift22
2 files changed, 25 insertions, 2 deletions
diff --git a/src/objective-c/examples/SwiftSample/Bridging-Header.h b/src/objective-c/examples/SwiftSample/Bridging-Header.h
index a85f7f7a5a..3b2ae74d8b 100644
--- a/src/objective-c/examples/SwiftSample/Bridging-Header.h
+++ b/src/objective-c/examples/SwiftSample/Bridging-Header.h
@@ -34,5 +34,10 @@
#ifndef SwiftSample_Bridging_Header_h
#define SwiftSample_Bridging_Header_h
+#import <RxLibrary/GRXWriteable.h>
+#import <RxLibrary/GRXWriter.h>
+#import <RxLibrary/GRXWriter+Immediate.h>
+#import <GRPCClient/GRPCCall.h>
+#import <ProtoRPC/ProtoMethod.h>
#endif
diff --git a/src/objective-c/examples/SwiftSample/ViewController.swift b/src/objective-c/examples/SwiftSample/ViewController.swift
index 73dd953167..dedcce20e7 100644
--- a/src/objective-c/examples/SwiftSample/ViewController.swift
+++ b/src/objective-c/examples/SwiftSample/ViewController.swift
@@ -37,7 +37,25 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
- // Do any additional setup after loading the view, typically from a nib.
+
+ let RemoteHost = "grpc-test.sandbox.google.com"
+
+ // Same example call using the generic gRPC client library:
+
+ let method = ProtoMethod(package: "grpc.testing", service: "TestService", method: "UnaryCall")
+
+ let requestsWriter = GRXWriter(value: NSData())
+
+ let call = GRPCCall(host: RemoteHost, path: method.HTTPPath, requestsWriter: requestsWriter)
+
+ let responsesWriteable = GRXWriteable { (value: AnyObject?, error: NSError?) in
+ if let value = value as? NSData {
+ NSLog("Received response:\n\(value)")
+ } else {
+ NSLog("Finished with error: \(error!)")
+ }
+ }
+
+ call.startWithWriteable(responsesWriteable)
}
}
-