meowmeowmeow
meowmeowmeow

Reputation: 762

how to handle Set properties in CoreData

I have an object, EventReminder, that contains 2 Set objects:

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
}

I want to convert this to CoreData but I'm having trouble mapping it all out. My class has a many-to-many relationship with NSDate(via importantDates) and DayOfWeek(via recurringDays).

Do I:

  1. make 2 classes of importantDates and recurringDays that hold only 1 property each: NSDate and DayOfWeek?

  2. create a relationship between EventReminder and these 2 classes?

  3. Do I have to make the enum DayOfWeek compliant to NSCoding? (not really sure if this is even possible)

Am I on the right track for the solution or is there a better way to do this?

Upvotes: 0

Views: 35

Answers (1)

trapper
trapper

Reputation: 11993

Don't make a seperate NSManagedObject just to hold an NSDate or an enum.

You can store a Set in CoreData, just make the type transformable with custom class Set.

Upvotes: 2

Related Questions