After many attempts and not getting anything displayed in my NSImageView I found this link http://stackoverflow.com/questions/5237703/displaying-an-image-in-cocoa and it was just about what I had but I still get nothing. The result of this is crashing the program with this error "unrecognized selector sent to instance" I know enough from you guys that it is sending to an object that is not there. But if I instantiate it 'myBackGroundView = [[NSImageView alloc] init];' no crash but no image? In IB I dragged out a Custom View from the library and did the connections.
header file
header file
Code:
IBOutlet NSImageView *myBackGroundView;
Code:
-(void)awakeFromNib{
NSString *imagePath = @"/Users/larspro/Documents/xpImages/xpbackground.png";
if (imagePath == nil) { //check a valid path.
NSLog(@"NO IMAGE");
}
NSImage *testImage = [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
if ( [testImage isValid] ) {
[myBackGroundView setImage:testImage];
}
else
{
NSLog(@"Not Working up");
}