I am making a simple notes app and when starting the app it gives me the error, "NSArray element failed to match Swift Array Element Type". Though there are many other questions like this, none of them had the problem in a tableViewController when putting the
cell.textLabel!.text = noteTitles[indexPath.row].title
Here is my full code and the class for the array:
Code:
class TableViewController: UITableViewController {
var noteTitles:[Note] = []
// MARK: - Table view data source
override func tableView(tableView: UITableView,
numberOfRowsInSection section: Int) -> Int {
return noteTitles.count
}
override func tableView(tableView: UITableView,
cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell",
forIndexPath: indexPath) as UITableViewCell
cell.textLabel!.text = noteTitles[indexPath.row].title // Error here.
return cell
}
}
And the Note Class:
class Note {
var title = ""
var content = ""
}
Please help me and tell me what I am doing wrong and help me fix it. Thank you in advance!
Here is image as asked of NSCoding error:
Here is image of KeyedUnarchiver error:
Noteclass implementation as well? - MarkNotes ? The error message says that the array doesn't haveNoteobjects in it. - Paulw11