I am trying to get an array of objects (which are retrieved from Parse in the application) from the parent application that will be displayed in the watch application. I tried several different things, but without success.
Here is my code in the extension:
override func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) var parkPassed = context as! String openParentAppWithPark(parkPassed) } private func openParentAppWithPark(park: String) { WKInterfaceController.openParentApplication(["request": park], reply: { (reply, error) -> Void in println(reply) }) }
And the code in the parent application:
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) { println("Test") if let userInfo = userInfo, request = userInfo["request"] as? NSArray { if request == "Park 1" { DataManager.sharedInstance.loadRides("Park 1") } else if request == "Park 2" { DataManager.sharedInstance.loadRides("Park 2") } else if request == "Park 3" { DataManager.sharedInstance.loadRides("Park 3") } else { DataManager.sharedInstance.loadRides("Park 4") } let rides = DataManager.sharedInstance.rideArray println("Rides: \(rides)") reply(["rideData": rides]) return } reply([:]) }
println I always return nil the first time I try to load, and then [:] every time. I assume this is because the request is disconnected before the application has time to load data from Parse? In addition, println , which should print "Test", is never called.
ios swift watchkit apple-watch
user3746428
source share