I am trying to receive an array of objects (that are retrieved from Parse within the app) from a parent application to be displayed in the watch application. I have been trying a few different things but with no success.
Here is my code in the extension:
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
var parkPassed = context as! String
println(parkPassed)
openParentAppWithPark(parkPassed)
}
func openParentAppWithPark(park: String) {
WKInterfaceController.openParentApplication(["request": park], reply: { (reply, error) -> Void in
println(reply)
})
}And the code in the parent app:
func beginBackgroundUpdateTask() -> UIBackgroundTaskIdentifier {
return UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler({})
}
func endBackgroundUpdateTask(taskID: UIBackgroundTaskIdentifier) {
UIApplication.sharedApplication().endBackgroundTask(taskID)
}
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {
println("Test")
if let userInfo = userInfo, request = userInfo["request"] as? NSArray {
let taskID = beginBackgroundUpdateTask()
if request == "Park1" {
DataManager.sharedInstance.loadRides("Park1")
} else if request == "Park2" {
DataManager.sharedInstance.loadRides("Park2")
} else if request == "Park3" {
DataManager.sharedInstance.loadRides("Park3")
} else {
DataManager.sharedInstance.loadRides("Park4")
}
let rides = DataManager.sharedInstance.rideArray
println("Rides: \(rides)")
reply(["rideData": rides])
endBackgroundUpdateTask(taskID)
return
}
}At the moment I am just recieving the nil every time. I assume this is because the app doesn't have time to load all of the objects into the array from parse before it tries to pass it back to the watch? In my main app I have added an observer that updates the table view when the array is ready, but I'm not sure how I would do that in this situation.
Anyone have any suggestions?
Thanks!