开发者

Binding to an NSDictionary's "allValues" array

开发者 https://www.devze.com 2022-12-20 23:42 出处:网络
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

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 de开发者_C百科al with this? Making relatively purposeless objects just to hold arrays in properties so I can bind to them seems ugly.


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消