2015-12-22 85 views
0

得到这个错误,而试图实现滑动删除 IMA初学者,所以不要用一个解释的帮助将是不错的 我的待办事项列表保存的文件 进口基金会滑动删除细胞

class TodoListsaved { 
class var sharedInstance : TodoListsaved { 
    struct Static { 
     static let instance : TodoListsaved = TodoListsaved() 
    } 

    return Static.instance 
} 

}

细胞FUNC

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

let cell = tableView.dequeueReusableCellWithIdentifier("cell",  forIndexPath: indexPath) as! TableViewCell 
    cell.selectionStyle = .None 
    let item = todoItems[indexPath.row] 
    cell.delegate = self 
    cell.toDoItem = item 
    return cell 

    //modify the cell to have check mark 
    if (item.completed) { 
     cell.accessoryType = UITableViewCellAccessoryType.Checkmark 
    } 

    else { 

     cell.accessoryType = UITableViewCellAccessoryType.None 

    } 



    return cell 
} 

我的数据源

进口的UIKit

class DataSource: NSObject { 

let itenName: String 
var completed : Bool 
var deadline : NSDate 
var UUID :String 

init(itenName :String , completed :Bool = false , deadline : NSDate , UUID :String ) { 
    self.itenName = itenName 
    self.completed = completed 
    self.UUID = UUID 
    self.deadline = deadline 
    //self.subTitle = subTitle 
    } 

} enter image description here

+0

具有u宣布在小区类文件的TodoItem变种? –

回答

0

在你TableViewCell类改变变量的TodoItem输入数据源如下:

class TablViewCell: UITableViewCell { 
var toDoItem: DataSource? 
} 
+0

谢谢它的工作 –

+0

如果它工作,请接受答案 –

0

当你宣称 'TableViewCell' 检查物业的TodoItem的类型设置为您打算类。同时检查数组todoItems的类型。它们应该是相同的,但是当我看到你的错误信息时,它们彼此不一样。

+0

谢谢,它的工作 –