Re: Show count of Core Data to-many relationship in NSTableView cell with bindings?
Re: Show count of Core Data to-many relationship in NSTableView cell with bindings?
- Subject: Re: Show count of Core Data to-many relationship in NSTableView cell with bindings?
- From: Steve Mills <email@hidden>
- Date: Fri, 06 Feb 2015 02:11:53 -0600
On Feb 6, 2015, at 01:56:24, Quincey Morris <email@hidden> wrote:
> You can’t bind *through* an array or set collection class. However, you can use these:
>
> https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/CollectionOperators.html
>
On Feb 6, 2015, at 02:03:34, Ken Thomases <email@hidden> wrote:
> You can't use KVO or bindings through arrays or sets, even to their immediate properties.
>
> For KVC, if you were to attempt to do [theTableCellView valueForKeyPath:@"objectValue.images.count"], that would attempt to get the "count" property of each _element_ of objectValue.images and return a set containing all of those counts (wrapped in NSNumbers). In theory, if KVO through sets worked, then observing the key path objectValue.images.count would not notify you when the count of objectValue.images changed. It would notify you when the set returned by [theTableCellView valueForKeyPath:@"objectValue.images.count"] changed (or might have changed). That's not what you want, anyway.
>
> However, there are collection operators <https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/CollectionOperators.html>, including @count. You can bind to that with model key path objectValue.images.@count.
Weeeellll doggies! Just when I was about to go to bed, you guys come through with the goods and make my night. :) Thanks so much. I need to read the KVC and KVO articles again.
--
Steve Mills
Drummer, Mac geek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden