我有一个带NSFetchedResultsController
的tableView!它运作良好。我想像许多iOS应用程序一样在tableViewCell上显示日期。当我向列表中添加新项目后,NSManagedObjectContext
将NSDate
保存为let entity:Manager = NSEntityDescription.insertNewObjectForEntityForName("Manager", inManagedObjectContext: self.managedObjectContext) as! Manager
entity.setValue(textField.text, forKey: "title")
entity.setValue(NSDate(), forKey: "time")
do { try self.managedObjectContext.save()
} catch {
}
,如此:
cellForRowAtIndexPath
这是我的func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(ReuseIdentifierToDoCell, forIndexPath: indexPath) as! CustomTableViewCell
if let access:Manager = self.frc.objectAtIndexPath(indexPath) as? Manager {
cell.firstLabel.text = access.valueForKey("title") as? String
cell.secondLabel.text = access.valueForKey("time") as? NSDate
}
方法!
time = "2016-02-01 06:16:15 +0000";
title = One;
一切都很完美!但我不需要像这样的默认时间:
"Control Panel" >> "System And Security" >> "Administrative Tools" >> "Component Services" >> "Services (LOCAL)"
我只需要时间和月份。 感谢您的关注!