Frage

I have an NSImageView that I placed in my NIB that I drag an image into. The image appears and displays, but when my code calls [imageView image], I get a NULL object.

War es hilfreich?

Lösung

In order for drag and dropping to work, you need to set the NSImageView as editable, either in Interface Builder or programmatically by using the method setEditable:. However, you've said the dropped image appears, so you've obviously enabled editing somewhere. The only other reason [imageView image] would return nil is if the NSImageView wasn't correctly connected to the object referencing it. You can check the connection by opening the .h file that the IBOutlet is defined and clicking on the filled-in dot to the left of the declaration. If the dot is unfilled, that means the connection hasn't been made and you need to go back into Interface Builder and make the connection. Here is an example of what you'll see when clicking a filled-in dot.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top