I'm trying to create an NSMatrix of an NSImageCell prototype programmatically (if you can help me doing it via Interface Builder, be my guest at answering me here)
I created a new, empty project. In it, a normal object (subclassing NSObject) has this code (and only this code):
- (void) awakeFromNib {
NSRect f = view.bounds;
NSMatrix* matrix = [[NSMatrix alloc] initWithFrame:f mode:NSListModeMatrix cellClass:[NSImageCell class] numberOfRows:1 numberOfColumns:1];
[matrix setCellSize:NSMakeSize(100, 100)];
[matrix sizeToCells];
[matrix setNeedsDisplay:YES];
[view addSubview:[matrix autorelease]];
[view setNeedsDisplay:YES];
NSLog(@"Matrix frame: %@", NSStringFromRect(matrix.frame));
}
"view" is an NSView specified as an outlet, connected to the Content View of the Window in Interface Builder.
The matrix does not show at all. It prints to log that the frame size is (0,0,100,100), as expected.
What am I doing wrong?
As the title states, I'm doing this on a Snow Leopard machine, using Xcode 3.2.1.