Questions : How do I use DateFormatter(Type: CLong) in tableview?
Similar questions I looked for
How to change JSON string to date format in tableview
I looked up questions like these on stackoverflow. However, there was no way to use Type: CLong.
Clong is a type I'm new to using, so I don't know what type to use Optional.
connection json file
struct BoardList: Codable {
var b_date: CLong?
}
TableViewController
var boards: [BoardList]?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell", for: indexPath) as! TableViewCell
if let boards = self.boards {
let model = boards[indexPath.row]
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy/MM/dd HH:mm:ss"
cell.txtDate.text = model.b_date // ERROR [Cannot assign value of type 'CLong?' (aka 'Optional<Int>') to type 'String?']
}
return cell
}
++ I must take the CLong type. Because the server value is specified in that format.