Skip to content

Instantly share code, notes, and snippets.

@billglover
Created May 27, 2015 05:54
Show Gist options
  • Save billglover/e02b61da5d1cc8dd1fff to your computer and use it in GitHub Desktop.
Save billglover/e02b61da5d1cc8dd1fff to your computer and use it in GitHub Desktop.
Using application:handleWatchKitExtensionRequest:reply: to pass Strings
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {
// expect a request String from the parent application
// send a response String in return
// Note: you may not see these in the console if debugging WatchKit
if let request: String = userInfo?["request"] as? String {
println("request: \(request)")
} else {
println("request received but not recognised")
}
var response: [NSObject: AnyObject] = [:]
response["response"] = "This is a String"
reply(response)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment