简体   繁体   English

iOS / objective-c / core-data:如何从相关实体获取属性

[英]IOS/objective-c/core-data: How to get attribute from related entity

I have a detail view where I display attributes of an object from an entity in core data. 我有一个详细视图,在其中显示核心数据中实体的对象属性。

The entity has a one-to-one relationship with another entity that has other data. 该实体与具有其他数据的另一个实体具有一对一的关系。 Because I don't understand relationships that well, it may not be set up correctly. 由于我不太了解关系,因此可能无法正确设置。

How can I display data from the other entity? 如何显示其他实体的数据?

In .h file, I have: 在.h文件中,我有:

 @property (nonatomic, strong) Persons *person;
    @property (nonatomic, strong) Addresses *address;
    @property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;

In .m file in viewDidLoad I have: 在viewDidLoad中的.m文件中,我有:

 self.nameLabel.text = self.person.name;//displays fine
 self.addressLabel.text = self.address.address//does not display
NSLog(@"address:%@",self.address.address);//displays (null)

Thanks for any suggestions. 感谢您的任何建议。

考虑到您已将人对象保存在视图控制器中,则只需按照person.address的关系获取其他实体。

暂无
暂无

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

相关问题 iOS / Objective-C / Core-data:如何从objectID获取对象 - IOS/Objective-C/Core-data: how to get object from objectID iOS / Core-data / Objective-C:带有布尔值的NSPredicate - IOS/Core-data/Objective-C: NSPredicate with Boolean values IOS / Objective-C / Core-data:如何检测选择器控制器中是否选择了新图像 - IOS/Objective-C/Core-data: How to detect if new image picked in picker controller ios / objective-c / core-data:如何在NSManagedObjects中将关系显示为属性 - ios/objective-c/core-data: How to show relationship as property in NSManagedObjects IOS / Objective-C / Core-Data:关系对象附带新的Core Data对象吗? - IOS/Objective-C/Core-Data: Does new Core Data object come with relationship objects? ios / objective-c / core-data:managedobjectcontext类语法中的调用方法 - ios/objective-c/core-data: Call method in managedobjectcontext class syntax ios / xcode / objective-c:有什么方法可以链接到核心数据驱动页面中的其他视图控制器? - ios/xcode/objective-c: Any way to link to other view controller in core-data driven page? 如何基于核心数据实体和属性在搜索栏上进行搜索 - How to search on a search bar on the basis of Core-Data entity and attribute 如何让我的核心数据实体的属性在 objective-c 单元测试中可见 - How do I get my Core Data entity's attributes to be visible in objective-c unit tests 如何从Objective-C中的XPath获取1个属性 - How to get 1 attribute from XPath in Objective-C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM