• 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
Problem on reload data source of a table view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem on reload data source of a table view


  • Subject: Problem on reload data source of a table view
  • From: JArod Wen <email@hidden>
  • Date: Sun, 13 Jul 2008 01:35:03 -0400

Hi all,

I met some problems on updating the content of my table with the following scenario:

My table is contained in a separated window(tableWindow.xib), so I use a TableController class to control it(File's Owner of the window). The following is the instant of TableController:

@interface TableController : NSWindowController {

	IBOutlet NSTableView*                dataTable;
	IBOutlet NSTableHeaderView*      headers;
	IBOutlet NSTableColumn*             column;
	IBOutlet TableSource*                  tableSource;
}

In IB I connected the window containing table view to "window" of File's Owner(TableController), and also table view to "dataTable". I have another TableSource class:

@interface TableSource : NSArrayController{
NSMutableArray * items;
NSMutableDictionary * parameters;
NSMutableDictionary * paramLabels;
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *)tableColumn row:(int)row;
- (void)tableView:(NSTableView *)aTableView
setObjectValue:anObject
forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex;


In this class, I store the data into the "items" array. I added an object for Table Source in IB and connected it to "tableSource" of File's Owner and also "dataSource" of table view of the window(tableWindow.xib).

There is a AppController which is used to initialize TableController with the following code:

-(void)loadTableController{
	if (tableController == NULL) {
		[self setTableController:[[TableController alloc] init]];
		if (![NSBundle loadNibNamed:@"tableWindow" owner:tableController]) {
		NSLog(@"Error loading TableController");}
		else{
			NSLog(@"TableController NIB Loaded");
		}
		[tableController loadWindow];
	}
}

When running, the window containing table can be showed correctly, and I can also initialize the column of the table by the following code:

		NSTableColumn* column = [[NSTableColumn alloc] init];
		[[column  headerCell] setStringValue:str1];
		[column setWidth:cWidth];
		[[[appController tableController] dataTable] addTableColumn:column];
		[column release];

The problem is that after I update the data source, which is tableSource in tableController, [dataTable reloadData] will not update the table view in the window. I have debugged the program and found that the content of data source has been updated, which means that, the updated information has been stored in data source. However, these changes cannot be showed in the table view in the window. I have checked the connection between dataTable and tableSource, and no problem found there.

Any suggestions on this problem? Thanks in advance!

---------------
JArod Wen




_______________________________________________

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: Problem on reload data source of a table view
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Setting Up Socket Streams
  • Next by Date: NSMenuItem custom view and isHighlighted
  • Previous by thread: Re: Re: How to make the FileOwner of a nib file accessible globally in whole project (JArod Wen)
  • Next by thread: Re: Problem on reload data source of a table view
  • Index(es):
    • Date
    • Thread