Skip to content

Instantly share code, notes, and snippets.

@billglover
Last active August 29, 2015 14:21
Show Gist options
  • Save billglover/692bcafeceae88a471fb to your computer and use it in GitHub Desktop.
Save billglover/692bcafeceae88a471fb to your computer and use it in GitHub Desktop.
Using openParentApplication:reply: to pass Strings
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBAction func ButtonPress() {
var userInfo: [NSObject: AnyObject] = [:]
userInfo["request"] = "This is a string"
// send a request String to the parent application
// expect a response String in return
WKInterfaceController.openParentApplication(userInfo, reply: {(reply, error) -> Void in
if let response: String = reply?["response"] as? String {
println("response: \(response)")
} else {
println("response received but not recognised")
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment