I have a Table View Controller Swift project in Xcode.
I have made a detailTextLabel for the deadline. I would want to add notes as this to appear immediately under the deadline(NSDate) as a second detailTextLabel(NSString), something like built-in Reminder app.
I tried to add it but every time I implement the second detailTextLabel, the deadline disappears and remains just the notes under the title. Also I tried to merge the 2 subtitles in a detailTextLabel but it couldn't because the deadline is NSDate and note is String.
Below is some of my codes:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("todoCell", forIndexPath: indexPath) // retrieve the prototype cell (subtitle style)
let todoItem = todoItems[indexPath.row] as ToDoItem
cell.textLabel?.text = todoItem.title as String!
if (todoItem.isOverdue) { // the current time is later than the to-do item's deadline
cell.detailTextLabel?.textColor = UIColor.redColor()
} else {
cell.detailTextLabel?.textColor = UIColor.blueColor() // we need to reset this because a cell with red subtitle may be returned by dequeueReusableCellWithIdentifier:indexPath:
}
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "'Due' MMM dd 'at' h:mm a" // example: "Due Jan 01 at 12:00 PM"
cell.detailTextLabel?.text = dateFormatter.stringFromDate(todoItem.deadline)
// When I try to add the detailTextLabel for note the deadline disappears
// cell.detailTextLabel?.text = todoItem.note as String!
return cell
}