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

Re: NSTableView


  • Subject: Re: NSTableView
  • From: Erik Buck <email@hidden>
  • Date: Wed, 14 Jan 2009 12:28:45 -0800 (PST)

The code provided looks very unusual and clearly does not follow the Model-View-Controller design.  It is almost always a bad idea to store information in the user interface.  
 
The following line is extremely suspect:
int count =  _browserView->fileList.GetCount();
 
Why doesn't your tableView's data source have its own direct reference to fileList ?
 
I suggest the following:
 
- (int)numberOfRowsInTableView:(NSTableView *)tableView {
   int count = 0;

   if(_fileList != NULL)
   {
       count = _fileList.GetCount();
   }
   
   return count;
}

 
What is going on with the following?
       [_browserView selectAll:self];
       [_browserCells release];
       _browserCells = [_browserView selectedCells];
       [_browserCells retain];        

Don't select stuff in - (int)numberOfRowsInTableView:
 
Even if you wanted the cells from the matrix for some reason, why not
[_browserCells release];
_browserCells = [[_browserView cells] copy];
 
But using the cells of a matrix outside the matrix is extremely suspect.  The cells should not contain any information that you can't get from some other source like _fileList.
 
The rest of teh code that copies information out of cells in a matrix in order to set information in cells used by a tableView  is so horrific that I won't comment any more.  Please read about Model-View-Controller.
 
_______________________________________________

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: NSTableView
      • From: David Blanton <email@hidden>
  • Prev by Date: UITableViewController with dynamic data
  • Next by Date: Re: UITableViewController with dynamic data
  • Previous by thread: Re: NSTableView
  • Next by thread: Re: NSTableView
  • Index(es):
    • Date
    • Thread