CoreData adding relationships to-many

前端 未结 1 1839
星月不相逢
星月不相逢 2021-02-06 15:27

In coredata I can work with one Entity fairly well, mostly because its nicely documented on the internet. However when i get to relationships i keep finding the same data over a

相关标签:
1条回答
  • 2021-02-06 16:12

    Read Custom To-Many Relationship Accessor Methods. You can use the standard -mutableSetValueForKey: method to access your relationship:

    NSMutableSet *ergTimes = [person mutableSetValueForKey:@"ergTimes"];
    [ergTimes addObject:newErgTime];
    

    Or, if you need to do the above in a number of places, you might want to implement an accessor for the 'ergTimes' property so that you can add a time directly:

    [person addErgTimesObject:newErgTime];
    

    Examples are given in the section I cited above.

    0 讨论(0)
提交回复
热议问题