NSBrowserDelegate gets passed nil matrix
NSBrowserDelegate gets passed nil matrix
- Subject: NSBrowserDelegate gets passed nil matrix
- From: Philip White <email@hidden>
- Date: Mon, 28 Sep 2009 08:57:59 -0500
Hello,
I'm having some problems with an NSBrowser in my application upon
upgrading to Snow Leopard. The browser is a simple two column setup. I
have setup the delegate as an "active delegate" to use Apple's
parlance from their developer docs. So I implement
- (void)browser:(NSBrowser *)sender createRowsForColumn:(NSInteger)
column inMatrix:(NSMatrix *)matrix
to create and setup the cells.
and
- (BOOL)browser:(NSBrowser *)sender isColumnValid:(NSInteger)column
Everything is good when I first choose an item in column 0.
browser:createRowsForColumn: is called and everything goes well. But
then if I select a different item in column 0,
browser:createRowsForColumn: is called for column 1 but the third
argument (the one I'm abbreviating away: inMatrix:(NSMatrix*), get's
passed nil. Needless to say, that doesn't do it for me.
So the second column ends up with it's previous contents. Then,
clicking on one of those items results in a:
NSInternalInconsistencyException -- Invalid parameter not satisfying:
cols == 1
Again, this was working in 10.5. Was I just lucky before?
Here is my code for that method, abbreviated:
- (void)browser:(NSBrowser *)sender createRowsForColumn:(NSInteger)
column inMatrix:(NSMatrix *)matrix
{
if (matrix == nil)
{
NSLog(@"matrix == nil");
}
if (column == 0) //the Notebook column
{
NSInteger count = [[SBNotebookOrganizer organizers] count];
[matrix renewRows:count columns:1];
NSInteger i;
for (i=0; i<count; i++)
{
id cell = [matrix cellAtRow:i column:0];
NSString *notebookTitle;
/*
A bunch of stuff here to get the title
...
*/
[cell setTitle: notebookTitle];
[cell setLeaf:NO];
}
}
else if (column == 1)
{
//pagesView is the browser
NSString *notebookTitle = [[pagesView selectedCellInColumn:0] title];
SBNotebookOrganizer *organizer = [SBNotebookOrganizer
organizerForTitle:notebookTitle];
NSInteger count = [organizer pageCount];
[matrix renewRows:count columns:1];
NSInteger i;
for (i=0; i<count; i++)
{
id cell = [matrix cellAtRow:i column:0];
NSString *title;
//some stuff here to get the title
...
//
[cell setTitle: title];
[cell setLeaf:YES];
}
}
else
{
Debugger();
}
}
Thanks!
-Philip
_______________________________________________
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