Bindings/KV Too Magical
Bindings/KV Too Magical
- Subject: Bindings/KV Too Magical
- From: Gregory Holden <email@hidden>
- Date: Sun, 2 Aug 2009 21:07:57 -0400
Some n00b questions about Bindings/KV I'm facing:
1) NSArrayController and canRemove, how does it know?
A familiar example to those who ran through Aaron Hillegass' Learning
Cocoa Programming.
I have an NSArrayController, an NSButton, and an NSTableView
- NSArrayController's contentArray is an NSMutableArray in a
MyDocument class.
- NSButton sends the action 'remove:' to the NSArrayController on click
- The column in NSTableView has a binding to NSArrayController to
display 'arrangedObjects.personName'
The last piece is the magical piece that is driving me nutty. The
NSButton has a binding enabled = NSArrayController's -(BOOL)canEnable.
I can't figure out how the NSArrayController knows when the
NSTableView has a row selected.
---------------------
2) requires 'insertObject:in<key>AtIndex' for
'removeObjectFrom<key>AtIndex' to work
If I don't implement 'insertObject:in<key>AtIndex' then
'removeObjectFrom<key>AtIndex' is never called. Why? The only reason
I can come up with is possibly a shortcut in Cocoa that if insert is
not implemented then remove probably isn't either.
Which bring me to my next question, how does it know the insert is
implemented?
I overrode:
-(BOOL)respondsToSelector:(SEL)aSelector
but it never queries for the insert. What magic does it work with?
Any help is GREATLY appreciated. I hate magic and I can't seem to
figure out the under-workings.
Thanks
G
_______________________________________________
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