【发布时间】:2017-05-16 14:11:52
【问题描述】:
我继承了一个在此行崩溃的 iOS 应用程序(意外为零)。您对这里发生的事情的最佳解释是什么?
indexPath.row.number == selectedItem ? cell.deselectStyle() : cell.dedeselectStyle()
cell.deselectStyle() 和 cell.dedeselectStyle() 函数不返回任何内容。我似乎找不到任何关于这里发生了什么的信息。 selectedItem 是 NSNumber!。
【问题讨论】:
-
selectedItem为零,这就是它崩溃的原因 -
我明白了,我只是想知道
?之后的所有内容有什么意义。 -
if (indexPath.row.number == selectedItem){cell.deselectStyle()} else{cell.dedeselectStyle()}他们返回的东西没关系。这不是您似乎误解的if (selectedItem){indexPath.row.number = cell.deselectStyle()} else{indexPath.row.number = cell.dedeselectStyle()} -
如果条件为真,则调用这个
cell.deselectStyle()。如果为 false,则调用此cell.dedeselectStyle()。 -
哦,好的,我现在看到了。
标签: swift legacy-code