我正在做Apple Watch App,其中并发症。对`ComplicationController'使用`InterfaceController`逻辑
我已经得到了WatchKit应用部分与该Ev
类工作的伟大 ...
class Ev {
var evTColor:String
var evMatch:String
init(dataDictionary:Dictionary<String,String>) {
evTColor = dataDictionary["TColor"]!
evMatch = dataDictionary["Match"]!
}
class func newEv(dataDictionary:Dictionary<String,String>) -> Ev {
return Ev(dataDictionary: dataDictionary)
}
}
...这InterfaceController
func session(session: WCSession, didReceiveUserInfo userInfo: [String : AnyObject]) {
if let tColorValue = userInfo["TColor"] as? String, let matchValue = userInfo["Match"] as? String {
receivedData.append(["TColor" : tColorValue , "Match" : matchValue])
evs.append(Ev(dataDictionary: ["TColor" : tColorValue , "Match" : matchValue]))
doTable()
} else {
print("tColorValue and matchValue are not same as dictionary value")
}
}
func doTable() {
self.rowTable.setNumberOfRows(self.evs.count, withRowType: "rows")
for (index, evt) in evs.enumerate() {
if let row = rowTable.rowControllerAtIndex(index) as? TableRowController {
row.mLabel.setText(evt.evMatch)
row.cGroup.setBackgroundColor(colorWithHexString(evt.evTColor))
} else {
print("nope")
}
}
}
我有一个硬在我的Complication中获得同样的东西,任何想法?
我不确定我是否可以对我的ExtensionDelegate
使用相同的Ev
代码,然后确定要放入我的ComplicationController
。
如果我用我的ExtensionDelegate
我得到一个致命错误相同Ev
代码:使用未实现初始化的init()的。
在我ComplicationController
我不知道如何去使用最好的我已经从InterfaceController
有数据ComplicationController
填写getCurrentTimelineEntryForComplication
& getTimelineEntriesForComplication
方法。
将根据需要发布任何额外的代码,谢谢!
编辑: 每一个问题,我的数据来自CloudKit的iPhone应用程序(我然后通过WCSession
传递到监视应用程序,所以我的问题是访问在我的收藏应用程序的数据为我并发症)
你的数据来自哪里?数据库?一个远程API? –
CloudKit将数据提供给iPhone应用程序,然后将该数据传递给Watch应用程序。这部分工作很好,我只需要访问我的手表应用程序的数据,以填补你知道的并发症? (我会在我的问题中注意到CloudKit的一部分) – SRMR