Joel Mathew
Joel Mathew

Reputation: 203

What are CoreDataGeneratedAccessors?

When I created a CoreData object with a one-to-many relationships, I get some methods (CoreDataGeneratedAccessors). Do we need to implement these methods? The methods generated automatically are given below :

- (void)addCirqitsObject:(Cirqit *)value;
- (void)removeCirqitsObject:(Cirqit *)value;
- (void)addCirqits:(NSSet *)value;
- (void)removeCirqits:(NSSet *)value;

Upvotes: 19

Views: 7752

Answers (2)

Florian Mielke
Florian Mielke

Reputation: 3360

You do not have to implement those methods, but you can. In the case you don't, CoreData will generate them dynamically for you.

If you want override the default implementation please read the Core Data Programming Guide (Custom To-Many Relationship Accessor Methods) to find a sample implementation.

A reason to override might be to trigger additional calculations or updates before or after new Cirqit objects being added or removed. But be aware of not to change the sample implementation code, just add your custom code - otherwise you might break your relationships handling.

Upvotes: 10

Kundan
Kundan

Reputation: 3082

You can override the core data generated accessors. You have to pay attention to a few special things like calling willChangeValueForKey and didChangeValueForKey, but other than that overriding the accessors is pretty much the same as always.

Courtesy:-https://stackoverflow.com/a/9659750/1865424

I think these links can help you..

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html

Upvotes: 0

Related Questions