简体   繁体   English

来自多个核心数据实体的tableview迅速

[英]tableview from multiple core data entities swift

I am struggling with something I think should be basic but cannot figure out. 我正在努力做一些我认为应该是基本但无法弄清楚的事情。 I have two entities in core data with a one to one and one to many relationship. 我在核心数据中有两个实体,它们之间具有一对一和一对多的关系。 They are Company which can have multiple Opportunities.I want to load a table view listing the opportunities (sorted by name) with their associated companies. 他们是可以拥有多个商机的公司。我想加载一个表格视图,列出与其关联公司相关的商机(按名称排序)。 Can this be done by simply accessing the Opportunity entity? 可以仅通过访问商机实体来完成此操作吗? If so, how do I access company? 如果是这样,我如何进入公司? The Opportunity class references it as a "Company" type and so I tried to go using dot notation through to company.companyName but it failed on that, and if I change it to simply company (of type Company) it does show .Company: and other reference data but not the simple name field I am looking for. Opportunity类将其引用为“ Company”类型,因此我尝试使用点符号到company.companyName,但此操作失败,并且如果将其更改为简单的Company(类型Company),则确实显示.Company:和其他参考数据,但不是我要查找的简单名称字段。 This seems as if it should be simple but........... 似乎应该很简单,但是..............

This was simple and I was overlooking the ability to load the fetchedresultscontroller with the right type (in my case the Opportunity class) and then use dot notation from there. 这很简单,我忽略了使用正确的类型(在我的情况下为Opportunity类)加载fetchedresultscontroller的能力,然后从此处使用点表示法。 I was trying to do it with key value access which did not work. 我试图用无效的键值访问来做到这一点。 Cheers 干杯

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

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