0

I have a document window with an empty NSImageView, and I have an outlet connect to this called *imageView. I also have the property: NSImage *image.

The NSImageView fills almost the entire window.

In windowControllerDidLoadNib: I call the following method:

-(void)addImageToImageView {
  imageView = [[NSImageView alloc] init];
  imageView.image = image;
}

There is definitely an image assigned to imageView.image but it does not display. I thought maybe it's because I'm adding the image to the view before the window is loaded but shouldn't all the code in windowControllerDidLoadNib run after the window has loaded?

Any help would be most welcome!

user3574603
  • 3,364
  • 3
  • 24
  • 59

1 Answers1

0

OK so:

Do NOT alloc init IBOutlets, these are references to objects that are instantiated by IB. Simply put what a .xib or .storyboard file is is information stored in XML format that is then unarchived automatically by your app (under the hood stuff). Therefore you should never alloc init an object that you've added in the interface builder.

What you've done above is change the variable *imageView from referencing whats in IB to a new imageView instance that isn't on screen.

You should check out some tutorials. There are some really good ones on youtube just search for them.

Rob Sanders
  • 5,197
  • 3
  • 31
  • 58