NSArrayController 添加:并编辑
我有一个简单的表格视图,显示我的应用程序应考虑的文件扩展名。现在我希望用户能够添加/编辑表中的条目以添加自己的文件扩展名。我将扩展存储在包含字典的数组中的preferences.plist(NSUserdefaults)中:
plist
- Array (of fileExtensions)
- Dictionary (aFileExtension)
- String (actual extension string e.g. @".zip")
现在,我已将arrayController 绑定到Userdefaults,并将tableView 绑定到该arrayController。扩展显示正常。 快乐的脸
但是,每当我编辑一个条目时,它们都会突出显示正常,我可以编辑该条目,单击另一个条目,到目前为止一切都很好。当我关闭窗口并再次打开它时,原始值将被恢复,因此显然 arrayController 不会保留对 NSUserdefaults 的更改。
我需要在 IB 中勾选特定框吗?
I have a simple tableview that displays file extensions which should be considered by my app. Now I want the user to be able to add/edit the entries in the table to add their own file extensions. I store the extensions in the preferences.plist (NSUserdefaults) in an Array that contains Dictionaries:
plist
- Array (of fileExtensions)
- Dictionary (aFileExtension)
- String (actual extension string e.g. @".zip")
Now, I have bound an arrayController to the Userdefaults and have the tableView bound to that arrayController. The extensions display fine. happy face
However, whenever I edit an entry, they highlight fine, I can edit the entry, click on a different one, all fine so far. When I close the window and open it again, the original values are restored, so apparently the arrayController does not persist the changes to the NSUserdefaults.
Do I need to tick an specific box in IB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Soooo,经过一些测试,我发现在 IB 的 ArrayController 中检查“将内容处理为复合值”可以解决问题。我认为任何查找此线程的人都可能感兴趣。
Soooo, after some testing I found out that checking "Handles content as compound value" in the ArrayController in IB does the trick. Thought that might interest anybody looking up this thread.