Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding to an NSDictionary's "allValues" array

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.

like image 415
andyvn22 Avatar asked Jul 10 '26 16:07

andyvn22


1 Answers

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)

like image 180
Mike Abdullah Avatar answered Jul 13 '26 11:07

Mike Abdullah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!