核心数据KVC示例
抱歉强加,但如果有人能看一下这个并告诉我如何完成此操作,我真的很感激:
核心数据按源列表条目和右上角文本字段之间的数据关联按预期工作。
如果您手动输入字符串,textField2(右下)也是如此。如果您手动输入字符串。
我想在下部文本字段中附加一个字符串,在本例中是通用的“Hello!” (在 setText 方法中实现)并让它保持与源列表条目的关联。
总结一下:textField2 - 手动输入字符串,它按预期工作。附加编码字符串,它不会保持与源列表条目的关联。
这是示例项目。
再次感谢您的帮助。
Sorry to impose, but I would really appreciate it if someone would take a look at this and show me how to get this done:
Core Data works as expected with data associations between the Source list entry(s) and the upper right textField.
So does textField2 (lower right) if you manually type in a string.
I want to append a string in the lower textField, in this case a generic "Hello!" (implemented in the setText method) and have it also maintain it's association with the source list entry.
To summarize: textField2 - manually type in a string, it works as expected. Append the coded string, and it does not maintain it's association with the source list entry.
Here's the sample project.
Thanks again for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是我在
MyDocument
类中更新setText:
方法的方法:我认为您对值设置方向的假设是错误的。对象不从文本字段获取值。它是从对象中获取值的文本字段。因此,我通过获取
output
文本字段的当前值并向其附加一些内容来创建newValue
。然后,我获取[setText Selection]
对象(当前选定的对象)并将其textField2
属性设置为新值。此setValue:forKey
方法会自动使用textField2
属性的新值更新output
测试字段。Here's how I updated
setText:
method inMyDocument
class:I think your assumptions on value setting direction was wrong. Object does not take a value from the text field. It's the text field that takes value from the object. Hence I create
newValue
by taking current value ofoutput
text field and appending something to it. Then I take[setText selection]
object (the one currently selected) and set it'stextField2
property to new value. ThissetValue:forKey
method automatically updates theoutput
test field with new value oftextField2
property.