(no subject)
(no subject)
- Subject: (no subject)
- From: Steve Cronin <email@hidden>
- Date: Sun, 14 Oct 2007 14:29:50 -0500
Folks;
I am trying to allow the user to manage which table columns are visible.
I have everything working very nicely within a given application launch.
I was under the impression that the tableView in the nib is archived
and not altered by any of the addTableColumn/removeTableColumn activity.
However, during a later application launch, when I read the [tv
tableColumns] in the tableView's -awakeFromNib what I find is that
only the columns which were visible when the application was last
terminated are there.
So when the user attempts to add back a column in this later run of
the application it fails because I no longer have anything which
points to the invisible columns....???
This is a non-document based app.
The table columns have bindings for value, fontName, fontSize, and
textColor.
Subclassed TableView
- (void) awakeFromNib {
NSArray * t = [self tableColumns];
NSMutableDictionary*workDict = [NSMutableDictionary
dictionaryWithCapacity:[t count]];
NSEnumerator * thisEnum = [t objectEnumerator];
NSTableColumn *tc;
while ((tc=[thisEnum nextObject])!=nil) {
[workDict setObject:tc forKey:(NSString *)[tc identifier]];
}
[self setMyTableColumns:workDict]; //this is an KVC compliant
dictionary instance var
}
WindowController
- (void) windowDidLoad {
...
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
if ([ud boolForKey:@"hideFistName"] == YES) [listTableView
removeTableColumn:[[listTableView myTableColumns]
objectForKey:@"firstName"]];
if ([ud boolForKey:@"hideLastName"] == YES) [listTableView
removeTableColumn:[[listTableView myTableColumns]
objectForKey:@"lastName"]];
...etc..
}
- (IBAction) toggleColumnVisibility:(id)sender {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSTableColumn *TC;
switch ([sender tag]) {
case 0:
TC = [[listTableView myTableColumns] objectForKey:@"firstName"];
if ([ud boolForKey:@"listDockHideFirstName"] == YES)
[listTableView removeTableColumn:TC];
else [listTableView addTableColumn:TC];
break;
case 1:
TC = [[listTableView myTableColumns] objectForKey:@"lastName"];
if ([ud boolForKey:@"listDockHideLastName"] == YES) [listTableView
removeTableColumn:TC];
else [listTableView addTableColumn:TC];
break;
...etc..
}
What am I doing wrong?
It all works great within one launch!
Thanks for any thoughts!
Steve
_______________________________________________
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