Database Reference
In-Depth Information
attachedPhoto . image = image
view . endEditing ( true )
} else {
titleField . becomeFirstResponder ()
}
}
This implementation will display the new image if the user has added one.
Next, open NotesListViewController.swift and update
tableView(_:cellForRowAtIndexPath) with the following:
override func tableView(tableView: UITableView , cellForRowAtIndexPath
indexPath: NSIndexPath ) -> UITableViewCell {
let note = notes . fetchedObjects [indexPath. row ] as Note
var identifier = "NoteCell"
if note. image != nil {
identifier = "NoteCellImage"
}
var cell = tableView. dequeueReusableCellWithIdentifier (identifier,
forIndexPath: indexPath) as NoteTableViewCell ;
cell. note = notes . fetchedObjects [indexPath. row ] as ? Note
return cell
}
This will set the correct cell identifier based on whether an image is present in the
note. If there is an image, you also need to populate the image view in the cell.
Open NoteTableViewCell.swift and add the following lines after the code that
sets the creation date label's text in updateNoteInfo() :
if let image = note ?. image {
noteImage . image = image
}
Build and run, and choose to add a new note:
Search WWH ::




Custom Search