• 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
NSTableView question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableView question


  • Subject: NSTableView question
  • From: Kip Wedel <email@hidden>
  • Date: Sun, 3 Jun 2007 12:32:08 -0500

I'm having trouble loading data into an NSTableView from its data source. I have an object of one class, FindController, which executes database queries and assembles found data into a mutable array of NSDictionary objects. Then it passes that array to an object of another class, TableController, to populate the table. FindController owns TableController.

The trouble is that TableController can't seem to "see" the table it's supposed to populate. I simply get nothing. Even the isKindofClass method returns null. As I've designed this, the NSTableView object itself is not passed as an id from the FindController to the TableController, rather its name is passed as a string. But TableController has been wired up as the table's data source in IB and has an outlet to the table. It also includes the two required methods,
numberOfRowsInTableView and objectValueForTableColumn. I designed it this way for a couple reasons. First, FindController and TableController have partially non-overlapping purposes, so it seemed logical and elegant to divide their duties into separate classes. Not all of the data FindController receives is displayed in NSTableView objects, and not all of the tables TableController populates receive data from FindController. Second, the app has multiple tables and I want TableController to populate all of them, choosing them dynamically.



Here's the relevant code in FindController.m:

if ([foundRecords count] > 0)
{
	KWTableController *tableController;
	tableController = [[KWTableController alloc] init];
	[tableController reload:@"findTable" withLoad:foundRecords];
	[tableController release];
}


In TableController.m:

-(void)reload:(NSString *)tableView withLoad:(id)dataToLoad
{
	if (tableView == @"findTable");
	{
		table = findTable;
		load = dataToLoad;
	}
	[table reloadData];
}


And in TableController.h:

@interface KWTableController : NSObject
{
IBOutlet NSTableView *findTable; // Eventually, I plan to add outlets to additional tables.
id table;
id load;
}
-(void)reload:(NSString *)tableView withLoad:(id)dataToLoad;
-(int)numberOfRowsInTableView:(NSTableView *)aTableView;
-(id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
@end



I thought the "table = findTable" assignment in TableController.m would pass the address contained in the *findTable pointer declared in TableController.h to the variable "table." Then "[table reloadData]" would know where to find the NSTableView object it is supposed to populate. However, not only does that not work, but even when I experiment with changing "[table reloadData]" to "[findTable reloadData]," calling an outlet explicitly identified in TableController.h, I still get nothing.


Not coming up with any better idea, I also tried removing the "[tableController release]" message in FindController.m, thinking maybe it was being released before it could do its job, but that didn't make any difference, either.

I hope I've explained this adequately. I'm a longtime AppleScripter, just getting started with Cocoa.

Kip

_______________________________________________

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


  • Follow-Ups:
    • Re: NSTableView question
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: Creating dynamic views
  • Next by Date: RS: RTF to unicode conversion
  • Previous by thread: Re: Blocking a method's return until an "async' forked thread has finished it's work.
  • Next by thread: Re: NSTableView question
  • Index(es):
    • Date
    • Thread