Ich übermittle Daten von iOS zu WatchKit. kann ich die Daten nicht bekommen, um zu zeigen, dass auf der WatchKit-Seite irgendwie empfangen wurde.WatchKit-Daten werden nicht angezeigt
Dies funktioniert gut: iOS TableViewController
func getCloudKit() {
///...
let publicData = container.publicCloudDatabase
publicData.performQuery(query, inZoneWithID: nil) { results, error in
if error == nil { // There is no error
for play in results! {
let newPlay = Play()
newPlay.tColor = play["TColor"] as! String
do {
try WatchSessionManager.sharedManager.updateApplicationContext(["color" : newPlay.tColor])
NSLog("NewPColor: %@", newPlay.tColor)
} catch {
print(error)
}
self.objects.append(newPlay)
}
} else {
print(error)
}
}
}
Dies ist eine der NSLog
s oder zeigt einen der Daten nicht aufrufen: WatchKit InterfaceController
import WatchConnectivity
class InterfaceController: WKInterfaceController, WCSessionDelegate {
@IBOutlet var colorLabel: WKInterfaceLabel!
private let session: WCSession? = WCSession.isSupported() ? WCSession.defaultSession() : nil
private func configureWCSession() {
session?.delegate = self;
session?.activateSession()
}
override init() {
super.init()
configureWCSession()
}
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
}
func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]) {
let colorWatch = applicationContext["color"] as? String
NSLog("Check if anything here: %@", colorWatch!)
dispatch_async(dispatch_get_main_queue()) {
if let colorWatch = colorWatch {
self.colorLabel.setText("From iPhone: \(colorWatch)")
NSLog("Heres all the strings %@", colorWatch)
} else {
NSLog("Nothing")
}
}
}
}
Irgendwelche Ideen? Vielen Dank! Überprüfung
Was WatchSessionManager ist, und es einzurichten WCSession nicht sicher, und es aktiviert? – ccjensen
'WatchSessionManager' ist eine Singleton-Klasse, um WCSession einzurichten und zu aktivieren. Das ist auf der iOS-Seite, so dass dieser Teil perfekt funktioniert, wenn ich alles protokolliere. Die WatchKit Seite ist die, die nicht gut funktioniert. Irgendwelche Ideen? – SRMR
Ist Session in configureWCSession() nicht vielleicht? – ccjensen