本文介绍了绑定到NSDictionary的“allValues”数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我是否误解绑定的问题?我绑定(一个NSArrayController的内容)到NSDictionary的allValues数组,并认为它是空的。我绑定到一个随机对象的属性,我已经设置为相同的NSDictionary的allValues数组,它工作正常。

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.

推荐答案

绑定到 @allValues表示向字典发送 -valueForKey:@allValues消息。然后,字典通过查找 -objectForKey:@allValues来解释它,这不是你在这种情况下的。

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.

尝试绑定到 @@ allValues(参见 - [NSDictionary valueForKey:] 更多详情)

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

这篇关于绑定到NSDictionary的“allValues”数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 13:51