Table column bindings to NSArrayController not working
Table column bindings to NSArrayController not working
- Subject: Table column bindings to NSArrayController not working
- From: Sam Stigler <email@hidden>
- Date: Thu, 17 May 2007 22:54:48 +1000
Hi,
I'm having a really strange problem: I'm using bindings for the
main table in my app, which displays content based on Core Data
objects, and that works fine. But for a smaller table, I'm
displaying content bound to an NSArray in my document controller
class (MyDocument).
Ideally, the second table (the one not based on Core Data) would
update after modifications made to its content array (or rather the
bound values of its columns, via an NSArrayController) during the
first table's -(void)tableViewSelectionDidChange:(NSNotification *)
aNotification method. Oddly enough GDB is telling me that that
method is working as it should; the array (called metadata) is being
updated, which leads me to believe there is a problem with the
bindings -- either that, or I did something wrong with how/where I
declared and allocated the array. I'm posting the relevant portions
of my code, as well as my bindings settings for that table, below;
could you please take a look and tell me if I'm doing anything wrong?
Thanks,
Sam
in MyDocument.h:
IBOutlet NSArrayController *metadataController;
IBOutlet NSMutableArray *metadata;
IBOutlet NSTableView *metadataTable;
in MyDocument.m:
- (void)windowControllerDidLoadNib:(NSWindowController *)
windowController
{
[super windowControllerDidLoadNib:windowController];
metadata = [NSMutableArray array];
[metadata retain];
-(void)dealloc
{
[metadata release];
[[NSApplication sharedApplication] setDelegate:nil];
[super dealloc];
}
towards the end of -(void)tableViewSelectionDidChange:
NSMutableDictionary *temp;
k = 0;
for (k; k < [md count]; k++) {
temp = [NSMutableDictionary dictionaryWithObject:[md
objectAtIndex:k] forKey:@"properties"];
[temp setValue:[mdattributes objectAtIndex:k] forKey:@"attributes"];
[metadata addObject:temp];
}
[metadataController prepareContent];
in MyDocument.nib:
NSArrayController called "metadata":
Automatically prepares content, Avoids empty selection, Preserves
selection, Selects inserted objects, Clears filter predicate on
insertion
Keys: attributes, properties
Binding:
contentArray:
Bind to: File's Owner (MyDocument)
Model Key Path: metadata
Raises For Not Applicable Keys
Table column 1: value = arrangedObjects.attributes [metadata
(NSArrayController)]
Conditionally Sets Enabled, Continuously Updates Value, Raises For
Not Applicable Keys
Table column 2: same, but with properties instead of attributes.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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