iPhone:存储和检索连接到 UIControl 的 NSManagedObject 的最佳方法
我是一个开发核心数据应用程序的初学者,该应用程序有两个实体 - “控制”和“值”,具有一对多关系。 (控制值)。每个“Control”代表一个 UIControl(UITextField、UIButton 等),它们以编程方式添加到 UIView。 “值”代表控件的值(文本、标题等)
由于视图可以有许多文本字段,如何将某个文本字段“连接”到特定的“值”?当我更改文本字段中的文本时,我想将其保存在相应的托管对象(值)中。我应该使用标签和 NSManagedObjectID 吗?
预先感谢您的任何建议。
I'm a beginner working on a Core Data app which has two Entities - "Control" and "Value" with a one-to-many relationship. (Control<-->>Value). Each "Control" represents a UIControl (UITextField, UIButton etc) which are added programmatically to a UIView. "Value" represents the control's value (text, title etc)
Since a view can have many text fields, how do I "connect" a certain text field to a specific "Value"? When I change the text in a text field I want to save it in the corresponding managed object (Value). Should I use tags and NSManagedObjectID?
Thanks in advance for any suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有很多方法可以解决这个问题。一种想法是在实体中包含一个“标签”列,并使用它来关联放入 UI 控件的标签值中的唯一值。
我也会问你是否“为什么”这样做,但我知道这确实不是问题。
Lot's of ways to approach this. One thought is to include a "tag" column in the entity and use that to correlate a unique value that gets put in the UI control's tag value.
I would also question whether "why" you're doing this, but I know that really wasn't the question.