NSArrayController design/usage question

2009-09-06 Thread Gregory Holden


NSArrayController seems great if you want to point it at repeating  
objects, but I can't find any clear way to add that one-off column  
that isn't part of the actual model objects (i.e. The "Now Playing"  
speaker in itunes, or a column with row numbers - independent of  
sorting).


I've tried a couple things myself, but feel the best thing to do is  
throw NSArrayController away in these situations, and stick to the  
DataSource.
Would this be an accurate assessment?  How have others dealt with this  
problem?


I did try setting up the bindings AND a datasource on the same table.   
It appears to work, but it also seems very dangerous as I'm obviously  
still getting requests for the bound data via  
tableView:objectValueForTableColumn.


Thanks
Greg
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Bindings/KV Too Magical

2009-08-02 Thread Gregory Holden

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:inAtIndex'   for
'removeObjectFromAtIndex'   to work
If I don't implement 'insertObject:inAtIndex' then  
'removeObjectFromAtIndex' 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com