I would like to bind NSTableColumn's headerTitle property to an NSMutableArray in my model layer (via an NSArrayController).
Basically I want to have an array where I can change values and have the table column header titles update. Is that reasonable?
However, the headerTitle
binding wants an single NSString
and I'm not sure how to connect my model object to this binding via my NSArrayController
. Google does not give many hits for this problem.
My model layer consists of two class (both of which are appropriately KVC compliant). The first is a model which represents a single column title, it has one property title
,
// A model class representing the column title of single NSTableColumn
@interface ColumnTitle : NSObject
@property NSString *title;
+ (ColumnTitle*) columnTitleWithTitle:(NSString*) aString;
@end
The second a model object which represents an ordered group of ColumnTitle objects,
// Class representing an order collection of model items
@interface TableColumnTitles : NSObject
@property NSMutableArray* columnTitles; // an array of ColumnTitle objects
// These are the KVC array accessors
-(void) insertObject:(ColumnTitle*)columnTitle inColumnTitlesAtIndex:(NSUInteger)index;
- (void)removeObjectFromColumnTitlesAtIndex:(NSUInteger)index;
- (void)replaceObjectInColumnTitlesAtIndex:(NSUInteger)index withObject:(ColumnTitle*)columnTitle;
@end
Note that TableColumnTitles
object implements the above array accessors which are required for the bindings. Any suggestions?