我想通過使用Swift在Xcode中創建一個TO-DO列表應用程序,並且遇到編寫「如果let path = indexPath {「表示」條件綁定中的綁定值必須是可選類型「的行。條件綁定中的綁定值必須爲可選類型[IOS - SWIFT]
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell
if let path = indexPath {
let currentString = dataSource[path.section][path.row]
cell.textLabel?.text = currentString
}
return cell
}
'indexPath'不是可選的,所以不需要解開它。 – Paulw11