Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. class func openParentApplication(userInfo: [NSObject : AnyObject], reply: (([NSObject : AnyObject], NSError?) -> Void)?) -> Bool
  2.  
  3. func updateInformationToParentApp(emergencyInfo : [NSObject : AnyObject]!){
  4.  
  5. // Call the parent application from Apple Watch
  6.  
  7. WKInterfaceController.openParentApplication(emergencyInfo) { (returnUpdate, error) -> Void in
  8.  
  9. if((error) == nil){
  10.  
  11. print("Data send successfully");
  12.  
  13. }else{
  14.  
  15. print("Error : (error?.localizedDescription)");
  16. }
  17. }
  18.  
  19. }
  20.  
  21. func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: ([NSObject : AnyObject]?) -> Void){
  22.  
  23. NSLog("Handler Apple Watch Event ");
  24. watchEvent(userInfo, reply: reply);
  25. }
  26.  
  27. func watchEvent(userInfo: [NSObject : AnyObject]!, reply: (([NSObject : AnyObject]!) ->Void)!) {
  28.  
  29. let dic = userInfo as NSDictionary;
  30.  
  31. NSLog("dic %@", dic);
  32.  
  33. // retrieved parameters from Apple Watch
  34. print(userInfo["Key"])
  35.  
  36. //Perform Segue from Here according to Dictionary Info
  37.  
  38. // pass back values to Apple Watch
  39.  
  40. var returnUpdate = Dictionary<String,AnyObject>()
  41.  
  42. let watchAppMessage = "Meesage Back To Apple Watch" as NSString;
  43. returnUpdate["message"] = NSKeyedArchiver.archivedDataWithRootObject(watchAppMessage);
  44.  
  45. reply(returnUpdate)
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement