NSMatrix help
NSMatrix help
- Subject: NSMatrix help
- From: James Andrews <email@hidden>
- Date: Tue, 5 Oct 2004 22:55:18 -0400
OK, so I've created NSMatrixes before with by doing an option drag,
but that is no good for what I want.
As I have mentioned before I want to mimic the thumbnail view of
iPhoto. Thinking about it, it seems to me that all it is, is an
NSMatrix of NSImageCells. My idea sounds sane to me, but my approach
was met with failure. This is what I did. To test my theory I
decided to just use NSTextCells. Here's my explanation of what I
tried, please tell me if you know where I went wrong.
I created a new project. In IB I added a button, a text field, and a
custom view. Changed the class on the view to NSMatrix. Created my
Controller, with an action and 2 outlets, one pointing to the view the
other to the text input field. And make the button access my single
action. This is the code for my action.
- (IBAction)addCell:(id)sender
{
NSCell * myText = [[NSCell alloc] initTextCell:[inputText objectValue]];
NSMutableArray * cellArray = [[NSMutableArray alloc] init];
[cellArray insertObject:myText atIndex:[cellArray count]];
if([myMatrix numberOfRows] == 0){
[myMatrix addRowWithCells:cellArray];
}
NSLog([[NSNumber numberWithInt:[myMatrix numberOfRows]] stringValue]);
NSLog([[NSNumber numberWithInt:[myMatrix numberOfColumns]] stringValue]);
}
When I build it I get no warnings or errors. Which is always nice to
see, but when I put text in the text field and click on the button I
get the following error.
2004-10-05 22:54:18.720 TestDraw[3296] *** Assertion failure in
-[NSMatrix insertRow:withCells:], AppKit.subproj/NSMatrix.m:1213
2004-10-05 22:54:18.727 TestDraw[3296] Invalid parameter not
satisfying: !newCells || ([newCells count] == _numCols)
I have a feeling that the custom view is not the way to go, but I am unsure.
TIA
-james
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden