I have all the data I need in my WatchKit Extension (passed from the iOS app).
I used the data in the WatchKit InterfaceController
to fill in a table, which works perfectly.
I'm trying to figure out the best way to get that same data in my WatchKit ComplicationController
.
Currently, in the InterfaceController
, the data gets passed in using didReceiveUserInfo
:
func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) {
if let beachValue = userInfo["Surf"] as? String {
places.append(Place(dataDictionary: ["Surf" : surfValue]))
} else {
print("Something went wrong")
}
}
Do I need to call this same WCSession
method in my ComplicationController
and do the whole data grab again, or is there any easier way for me to access this same data for use in the ComplicationController
?
Any help appreciated. Thanks!
EDIT:
My table function:
func makeTable() {
// Per SO
let myDelegate = WKExtension.sharedExtension().delegate as! ExtensionDelegate
let accessVar = myDelegate.places
self.rowTable.setNumberOfRows(accessVar.count, withRowType: "rows")
for (index, evt) in accessVar.enumerate() {
if let row = rowTable.rowControllerAtIndex(index) as? TableRowController {
row.mLabel.setText(evt.evMat)
} else {
print(“No”)
}
}
}