sudo rm -rf
sudo rm -rf

Reputation: 29524

Accessing NSImageView giving EXC_BAD_ACCESS

I've got a strange problem here.

I have a class that I'll call MainView. In MainView I have one NSImageView, which I'll call imageView. I've hooked this up to an image view through Interface Builder. I've also initialized an instance of MainView in Interface Builder, and have connected an outlet to that instance to another class with an ivar name of mainView. So then, I access the image view like this:

[mainView imageView]

So then, for a test I NSLog'd the imageView and it returned the address of the objet. So far so good.

Here's the problem: now I'm trying to get the origin of that imageView by doing this:

NSPoint point = [[mainView imageView] frame].origin;

This should work, right? I'm getting an EXC_BAD_ACCESS (also got a SIGABRT once) warning here with the error in console of: -[NSImage frame]: unrecognized selector sent to instance 0x1001d5fd0

The strange part is that this always used work just fine, but I changed some ivar names and it seemed to mess up the whole thing. I almost know for certain it's not a hookup issue with IB because I get a memory address when I log the object. Any ideas?

Upvotes: 1

Views: 308

Answers (1)

user557219
user557219

Reputation:

The error message

-[NSImage frame]: unrecognized selector sent to instance 0x1001d5fd0

means that imageView is pointing to an NSImage object instead of an NSImageView object. It looks like somewhere in your code you’re reassigning the imageView outlet, making it point to an NSImage instance.

Upvotes: 2

Related Questions