【发布时间】:2014-06-11 05:42:49
【问题描述】:
我不明白为什么在下面的代码中,indexPath.section 正在重新调整一个空值。
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? {
NSLog("Index Path %@", indexPath)
// Index Path <NSIndexPath: 0x1666d1d0> {length = 2, path = 0 - 0}
NSLog("Index Path Section %@", indexPath.section)
// Index Path Section (null)
在this question 之后,我还尝试了以下方法来访问部分值:
if let section = indexPath?.section {
NSLog("Index Path Section %@", section)
}
我有一个包含 2 个部分的表格,每个部分有 1 行。在path = 0 - 0 的第一次迭代中,日志显示Index Path Section (null)。在path = 1 - 0 程序崩溃的第二次迭代中。
我不想做任何复杂的事情,我只需要访问部分值,以便有条件地返回正确类型的单元格。
【问题讨论】:
标签: ios swift nsindexpath