【发布时间】:2015-01-14 22:28:19
【问题描述】:
我在包含应用程序和手表应用程序之间传递字符串数组时遇到问题,我之前发布了一个关于收到错误 String is not identical to AnyObject - 'String' is not identical to 'AnyObject' error 的问题
当我发布这个问题时,我是这样声明手表应用程序的数组的:
var tempNames = [""]
var tempAmounts = [""]
var tempDates = [""]
现在我这样声明它们:
var tempNames = []
var tempAmounts = []
var tempDates = []
这解决了另一个错误,但是我现在在另一行收到错误。现在,当我尝试在 TableView 中显示字符串时,我收到错误 'AnyObject' is not convertible to 'String'。这是我的代码:
for (index, tempName) in enumerate(tempNames) {
let rowNames = recentsTable.rowControllerAtIndex(index) as RecentsTableRowController
rowNames.nameLabel.setText(tempName)
}
for (index, tempAmount) in enumerate(tempAmounts) {
let rowAmounts = recentsTable.rowControllerAtIndex(index) as RecentsTableRowController
rowAmounts.amountLabel.setText(tempAmount)
}
for (index, tempDate) in enumerate(tempDates) {
let rowDates = recentsTable.rowControllerAtIndex(index) as RecentsTableRowController
rowDates.dateLabel.setText(tempDate)
}
我在rowNames.nameLabel.setText(tempName) 行收到错误消息。
我哪里错了?
【问题讨论】:
标签: ios nsarray nsuserdefaults watchkit apple-watch