2016-09-23 25 views
0

处理设置属性有一个对象,EventReminder,包含2个对象:我如何在CoreData

var importantDates: Set<NSDate> 
var recurringDays: Set<DayOfWeek> 
. 
. 
. 
enum DayOfWeek: Int { 
    case Sunday = 0 
    case Monday 
    case Tuesday 
    case Wednesday 
    case Thursday 
    case Friday 
    case Saturday 
} 

我想将其转换为CoreData,但我无法映射这一切了。我的班级与NSDate(通过importantDates)和DayOfWeek(通过recurringDays)具有多对多的关系。

我是否:

  1. 使2班的importantDatesrecurringDays持有各只有1属性:NSDateDayOfWeek

  2. 创建EventReminder和这两个类之间的关系?

  3. 是否必须使枚举DayOfWeek符合NSCoding? (真的不知道这是甚至可能)

我在解决方案的正确轨道或有没有更好的方法来做到这一点?

回答

1

不要单独制作NSManagedObject来保存NSDate或枚举。

您可以在CoreData中存储Set,只需使用自定义类Set进行类型转换即可。