if editingStyle == UITableViewCellEditingStyle.delete {
todos.remove(at: indexPath.row)
self.tableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
// self.tableView.reloadData()
}
todos.remove(at: indexPath.row)
self.tableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
// self.tableView.reloadData()
}
2017-05-25
let locale = NSLocale.current
let dateFormat = DateFormatter.dateFormat(fromTemplate: "yyyy-MM-dd", options: 0, locale: locale)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = dateFormat
date.text = dateFormatter.string(from: todo.date as Date)
let dateFormat = DateFormatter.dateFormat(fromTemplate: "yyyy-MM-dd", options: 0, locale: locale)
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = dateFormat
date.text = dateFormatter.string(from: todo.date as Date)
2017-05-25
let locale=NSLocale.current
let dateFormat=DateFormatter.dateFormat(fromTemplate: "yyyy-MM-dd", options: 0, locale: locale)
let dateFormater=DateFormatter()
dateFormater.dateFormat=dateFormat
date.text=dateFormater.string(from: todo.date as Date)
let dateFormat=DateFormatter.dateFormat(fromTemplate: "yyyy-MM-dd", options: 0, locale: locale)
let dateFormater=DateFormatter()
dateFormater.dateFormat=dateFormat
date.text=dateFormater.string(from: todo.date as Date)
2017-05-12
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cell=self.tableview.dequeueReusableCell(withIdentifier: "todocell")
let todo=Todos[indexPath.row] as TodoModel
let cell=self.tableview.dequeueReusableCell(withIdentifier: "todocell")
let todo=Todos[indexPath.row] as TodoModel
2017-05-12
class TodoViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Todos=[TodoModel(id:"1",image:"aaa.png",title:"去游乐场",date:dateFromString(dateStr:"2014-11-02")!)]
}
}
override func viewDidLoad() {
super.viewDidLoad()
Todos=[TodoModel(id:"1",image:"aaa.png",title:"去游乐场",date:dateFromString(dateStr:"2014-11-02")!)]
}
}
2017-05-12
import UIKit
var Todos:[TodoModel]=[]
func dateFromString(dateStr:String)->NSDate?{
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
let date = dateFormatter.date(from: dateStr)
return date as NSDate?
}
var Todos:[TodoModel]=[]
func dateFromString(dateStr:String)->NSDate?{
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
let date = dateFormatter.date(from: dateStr)
return date as NSDate?
}
2017-05-12
我 adding missing constraints 是灰的 点不了,我点的 reset to suggested constraints ~
2017-04-19
最新的、已测试正确~
let gregorian = Calendar(identifier:Calendar.Identifier.gregorian)
let now = Date()
let components = gregorian.dateComponents([.year], from: now, to: now)
let age = components.year
let gregorian = Calendar(identifier:Calendar.Identifier.gregorian)
let now = Date()
let components = gregorian.dateComponents([.year], from: now, to: now)
let age = components.year
2017-04-06