Re: Binding to an NSSet
Re: Binding to an NSSet
- Subject: Re: Binding to an NSSet
- From: Ken Thomases <email@hidden>
- Date: Fri, 5 Sep 2008 21:49:51 -0500
On Sep 5, 2008, at 8:58 AM, Chris Backas wrote:
I may be overlooking a relevant piece of documentation, but I have a
property which is a Set, and I want to use an NSArrayController and
an NSTable to manage it. NSArrayController has a "contentSet" key
that I bound to my set property without a problem, it displays in my
table just fine.
However, I'm trying to get better control over inserts into this
set, so I decided to implement the optional accessors. I've done
this in the past with arrays using something like this:
-(NSSet*)someProperty
-(void)insertObject:(id)object inSomePropertyAtIndex:(int)index
-(void)removeObjectFromSomePropertyAtIndex:(int)index
-(void)replaceObjectInSomePropertyAtIndex:(int)index withObject:
(id)object
However, these don't seem to apply to sets very well due the use of
an Index. I can't seem to find alternatives suited to sets either.
Basically I need to either replace, or call methods on the new
objects being inserted into the collection when NSArrayController's
add: gets called.
Check the documentation for the -mutableSetForKey: method defined by
the NSKeyValueCoding informal protocol.
(Curiously, the comments at the declaration of that method in
NSKeyValueCoding.h differs in item 4. I don't know which is correct,
but thought I'd point it out for completeness.)
Cheers,
Ken
_______________________________________________
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