I am currently a beginner learning Cocoa, and I've been writing a few test applications trying to figure out some of the things that aren't covered in Hillegass' "Cocoa Programming". My current problem is trying to load an NSMatrix created programmatically. I have an interface set with an outlet connected to an NSMatrix of NSTextFieldCells (declared in the header file as "matrix"), with the following code:
The values according to the log are correct for the new matrix, but the interface doesn't change. Is there a different way to load the new matrix other than -setNeedsDisplay? Or am I going about this all wrong? Any help is greatly appreciated.
Code:
@implementation AppController
- (IBAction)loadNewMatrix:(id)sender {
NSTextFieldCell* tc = [[NSTextFieldCell alloc] init];
matrix = [[NSMatrix alloc] initWithFrame:NSMakeRect(10,10,200,200)
mode:NSListModeMatrix
prototype:tc
numberOfRows:4
numberOfColumns:4];
[matrix setNeedsDisplay:YES];
[tc release];
int x = [matrix frame].origin.x;
int y = [matrix frame].origin.y;
int w = [matrix frame].size.width;
int h = [matrix frame].size.height;
NSLog(@"%d %d %d %d", x, y, w, h);
}
The values according to the log are correct for the new matrix, but the interface doesn't change. Is there a different way to load the new matrix other than -setNeedsDisplay? Or am I going about this all wrong? Any help is greatly appreciated.