让我摆一个姿势,缓慢伸出我的右手,面向swift,做“欲扶眼镜”状!!!
正题
闲话不想说了,实例化WKInterfaceTable的时候会报错,实例化代码如下:
let row = Table.rowController(at: index) as! tableList
如何避免
正确姿势,
func fillTable()
{
//set the rows
self.Table.setNumberOfRows(tableCount, withRowType: "tableList")
//necessary
for index in 0...tableCount-1
{
let row = Table.rowController(at: index) as! tableList
row.tableNumber.setText("\(tableNumMsg[index])")
row.tableMemo.setText("\(tableMemoMsg[index])")
}
}
for循环是必要的,然而最必要的是tableNumMsg
与tableMemoMsg
的定义,如下
var tableNumMsg = ["","","","","","","",""]
var tableMemoMsg = ["","","","","","","",""]
var tableDateMsg = ["","","","","","","",""]
var tableCount = 0
这样也算啊,只要你不要被Xcode检测出nil
就行了,啊啊啊啊啊啊啊啊啊啊啊啊啊啊,地球已经无法阻挡我了,赶紧听歌冷静一下!!!!!
看不懂??
请看官网说明,其实已经很明白了
【Class·WKInterfaceTable】