如何解决此问题?
在第5行
它向我显示此错误“无法在swift中调用'stringFromDate'错误 “
let today = NSData() let formatter = NSDateFormatter() formatter.dateFormat = "dd-MMM-yyyy" var newTask = NSEntityDescription.insertNewObjectForEntityForName("Tasks", inManagedObjectContext: context) as! NSManagedObject newTask.setValue(formatter.stringFromDate(today), forKey: "taskDate")
答案 0 :(得分:0)
你在单词NSDate中犯了一个错误。更改此行代码:
let today = NSData()
到此:
let today = NSDate()