I am trying to create an NSMatrix prototype of NSImageCell programmatically (if you can help me do this through Interface Builder, be my guest by answering me here )
I created a new empty project. In it, a regular object (subclassification of 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 output connected to a view of the contents of a window in the interface builder.
The matrix is not displayed at all. It prints for logging that frame size (0,0,100,100), as expected.
What am I doing wrong?
As the title says, I am doing this on a Snow Leopard machine using Xcode 3.2.1.