• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
TableColumn visibility issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TableColumn visibility issue


  • Subject: TableColumn visibility issue
  • From: Steve Cronin <email@hidden>
  • Date: Sun, 14 Oct 2007 14:43:35 -0500

Folks;
[Sorry for the earlier 'no subject' posting!!]

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


  • Follow-Ups:
    • Re: TableColumn visibility issue
      • From: Jerry Krinock <email@hidden>
    • Re: TableColumn visibility issue
      • From: Stéphane Sudre <email@hidden>
  • Prev by Date: (no subject)
  • Next by Date: Re: TableColumn visibility issue
  • Previous by thread: Re: Validation error in a relationship? (in coredata)
  • Next by thread: Re: TableColumn visibility issue
  • Index(es):
    • Date
    • Thread