Add Swift example with non-generated code :D

pull/3175/head
Jorge Canizales 10 years ago
parent 587c2550dd
commit 875d1d15c8
  1. 5
      src/objective-c/examples/SwiftSample/Bridging-Header.h
  2. 22
      src/objective-c/examples/SwiftSample/ViewController.swift

@ -34,5 +34,10 @@
#ifndef SwiftSample_Bridging_Header_h #ifndef SwiftSample_Bridging_Header_h
#define 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 #endif

@ -37,7 +37,25 @@ class ViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.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)
} }
} }

Loading…
Cancel
Save