Binding to an NSDictionary's “allValues” array

ぃ、小莉子 提交于 2020-01-24 10:27:49

问题


Am I misunderstanding something about bindings? I bind (an NSArrayController's content) to an NSDictionary's "allValues" array, and it thinks it's empty. I bind to a random object with a property that I've set to be that same NSDictionary's "allValues" array, and it works fine.

Is this expected behavior, or am I doing something wrong? Furthermore, if this is expected, what is the standard way to deal with this? Making relatively purposeless objects just to hold arrays in properties so I can bind to them seems ugly.


回答1:


Binding to @"allValues" means the dictionary is sent a -valueForKey:@"allValues" message. The dictionary then interprets that by looking up -objectForKey:@"allValues" which is not what you are after in this case.

Try binding to @"@allValues" instead (see the -[NSDictionary valueForKey:] docs for more details)



来源:https://stackoverflow.com/questions/2285844/binding-to-an-nsdictionarys-allvalues-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!