简体   繁体   English

关于通过核心数据自动生成代码的快速问题

[英]Quick question about auto-generated code via core data

I have two entities Company and Employees. 我有两个实体公司和雇员。 Company has a 1-to-many relationship with employees. 公司与员工有一对多关系。 An almost exact question was asked here however it doesnt answer my question :(. Like in that question, xcode in Company.m generates 4 almost exactly the same methods. However, the prototypes are not included in Company.h which leads me to believe that this is either 这里一个几乎确切的问题,但是它没有回答我的问题:(。像那个问题一样,Company.m中的xcode生成4个几乎完全相同的方法。但是,原型没有包含在Company.h中,这使我相信这是

  • An error and that company.h requires the 4 prototypes for the void functions described in. 一个错误,并且company.h需要使用4个原型来描述其中的void函数。
  • Intended and those 4 methods are only usable in the .m file? 目的和这4种方法仅在.m文件中可用? If so how to add many employees to a company. 如果是这样,如何在公司中增加许多员工。

Standing by for any clarifications. 等待任何澄清。 Thanks! 谢谢!

Typically I just set the company on the employee when creating the employees. 通常,我在创建员工时只是将公司设置在员工身上。

[newEmployee setValue:company forValue:@"company"];

this will trigger the relationship both ways and add the employee to the companies set of employees. 这将触发双向关系,并将员工添加到公司的员工集中。

or since you've subclassed it. 或因为您已经将其分类。

newEmployee.company = company;

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

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