Been learning Objective-C and Cocoa lately, but I've stumbled into a little problem with NSImage and NSImageView. Here's the code I use;
Code:
-(IBAction)buttonCP_Clicked:(id)sender
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
if([panel runModal] == NSOKButton)
{
NSString *filNavn = [panel filename];
NSImage *image = [NSImage imageNamed:filNavn];
[imageView setImage:image];
[textLabel setStringValue:filNavn];
}
}
EDIT:
Just tested the following code, and this doesn't work either:
Code:
-(void)awakeFromNib
{
NSImage *image = [NSImage imageNamed:@"/Users/Christian/Downloads/wine.jpeg"];
[imageView setImage:image];
}
The code compiles without any warnings or errors, when I press the Choose Picture (CP button) it opens a dialog, I choose my picture, and the label text is changed to the path, but the picture doesn't show up, at all. Any help would be appreciated! :-)
- Krillere