Pregunta

in order to load a PDF document into a PDFView I added Quartz.framework to my project.

Since then, although I haven´t even used it so far, I´m getting strange error messages: Multiple methods named 'state' found with mismatched result, parameter type or attributes

I´m using the state method which is from AppKit.framework/NSCell to check if checkboxes are on or off like this:

BOOL replaceCheckBoxFlag = ([sender state] == NSOnState);

The ImageCaptureCore.framework which is part of the Quartz.framework also owns a method state. How is it possible that Xcode get´s confused?

What can I do? Any hints?

Ronald

¿Fue útil?

Solución

This is happening because sender is declared as type id, which means that the compiler knows it's an Objective-C object, but it doesn't know what class it belongs to. So it looks though all the class definitions and it found two matches, and it doesn't know which one to use.

The solution is to either cast it or use a new variable of the correct type:

BOOL replaceCheckBoxFlag = ([(NSCell *)sender state] == NSOnState);

or

NSCell *cell = sender;
BOOL replaceCheckBoxFlag = ([cell state] == NSOnState);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top