简体   繁体   English

什么是CoreDataGeneratedAccessors?

[英]What are CoreDataGeneratedAccessors?

When I created a CoreData object with a one-to-many relationships, I get some methods (CoreDataGeneratedAccessors) . 当我创建一个具有一对多关系的CoreData对象时,我得到了一些方法(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;

You do not have to implement those methods, but you can. 您不必实现这些方法,但您可以。 In the case you don't, CoreData will generate them dynamically for you. 如果不这样做,CoreData将为您动态生成它们。

If you want overwrite the default implementation please read the Core Data Programming Guide (Custom To-Many Relationship Accessor Methods) to find a sample implementation. 如果要覆盖默认实现,请阅读“ 核心数据编程指南”(自定义多对多关系访问器方法)以查找示例实现。

A reason to overwrite might be to trigger additional calculations or updates before or after new Cirqit objects being added or removed. 覆盖的原因可能是在添加或删除新的Cirqit对象之前或之后触发其他计算或更新。 But be aware of not to change the sample implementation code, just add your custom code - otherwise you might break your relationships handling. 但请注意不要更改示例实现代码,只需添加自定义代码 - 否则可能会破坏您的关系处理。

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. 你必须注意一些特殊的事情,比如调用willChangeValueForKey和didChangeValueForKey,但除了覆盖访问器之外的其他内容几乎与以往一样。

Courtesy:- https://stackoverflow.com/a/9659750/1865424 礼貌: - 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 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM