Last active
August 29, 2015 14:21
-
-
Save billglover/692bcafeceae88a471fb to your computer and use it in GitHub Desktop.
Using openParentApplication:reply: to pass Strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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