2017-07-10 2 views
0

Ich versuche, mein Projekt auf Simulator auszuführen, aber die iOS-Seite wird nicht aktiviert und nur die Uhrseite kann aktivieren.WatchConnectivity wird auf iOS-Seite beim Ausführen auf Simulator nicht aktiviert

Hier ist meine ScoresInterfaceController.swift (Uhr Seite)

import WatchConnectivity  

class ScoresInterfaceController: WKInterfaceController, WCSessionDelegate { 

    // Used to send information to the iOS app 
    var applicationDict = [String: Int]() 

    // Starts a session to communicate with the iOS app 
    var session: WCSession! 

    // For WCSession 
    override init() { 
     super.init() 

     if(WCSession.isSupported()) { 
      session = WCSession.default() 
      session.delegate = self 
      session.activate() 
     } 
    } 

    func session(_ session: WCSession, 
      activationDidCompleteWith activationState: WCSessionActivationState, 
      error: Error?) {} 

Hier mein ScoreViewController.swift ist (iOS Seite)

import WatchConnectivity  

class ScoreViewController: UIViewController, WCSessionDelegate {  

    // Starts a session to communicate with the Watch app 
    var session: WCSession! 

    override func viewDidLoad() { 
     super.viewDidLoad() 
     // Do any additional setup after loading the view, typically from a nib. 

     if(WCSession.isSupported()) { 
      session = WCSession.default() 
      session.delegate = self 
      session.activate() //Not activating when run on Simulator  
     } 
    } 

    // For WCSession 

    /** Called when the session has completed activation. If session state is WCSessionActivationStateNotActivated there will be an error with more details. */ 
    @available(iOS 9.3, *) 
    func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {} 

    // Receives data from Watch app 
    @nonobjc func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]) {} 

    func sessionDidBecomeInactive(_ session: WCSession) {} 

    func sessionDidDeactivate(_ session: WCSession) { 
     WCSession.default().activate() 
    } 
} 

Hier ist die Fehlermeldung:

enter image description here

Ich folgte diesem Tutorial, aber ich kann nicht herausfinden, was die Frage ist:

http://kristina.io/watchos-2-how-to-communicate-between-devices-using-watch-connectivity/

Antwort

0

änderte meine ScoreViewController Definition der Sitzung von dieser:

@nonobjc func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]) {} 

dazu:

func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any]) 
Verwandte Themen