Created
May 27, 2015 05:54
-
-
Save billglover/e02b61da5d1cc8dd1fff to your computer and use it in GitHub Desktop.
Using application:handleWatchKitExtensionRequest: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 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