當我遍歷一個的tableView的所有單元格,在Objective-C:的cellForRowAtIndexPath在迅速和Objective-C
它的工作,但在迅疾我代碼:
for index in 0...tableView.numberOfRowsInSection(0) {
let cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: index, inSection: 0))!
cell.textLabel?.text = "\(index)"
}
墜毀,並拋出一個解包零錯誤。看來只能得到Swift中的可見單元格,並且可以獲取Objective-C中的所有單元格。如何解釋這一點?
您不應顯式調用'cellForRowAtIndexPath'來更改單元格文本標籤。 –