Last active
August 29, 2015 14:21
-
-
Save billglover/ce697e10eda3c6be8a8a to your computer and use it in GitHub Desktop.
Using application:handleWatchKitExtensionRequest:reply: to pass UIColor
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 UIColor 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"] = UIColor.blueColor() | |
reply(response) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment