How to auto generate NSManagedObject subclasses with date attribute as Date instead of NSDate?

烂漫一生 提交于 2019-12-01 17:27:08

It's not currently possible, because Core Data is still very much tied to Objective-C types, and this is one of the places it shows.

However, you can still assign a Date to an NSDate attribute:

    newEvent.timestamp = Date() as NSDate

It's far from ideal, but if you have other code that uses Date, you don't have to make it use NSDate instead. Use as to convert only when working directly with your managed objects.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!