I'm having problems with building my project in Xcode 4.5. Xcode gives me this error "Multiple methods named 'item' found with mismatched result, parameter type or attributes". Can someone tell me what the problem is? how to resolve multiple methods names error?
问题:
回答1:
You probably have different classes implementing the method item
but returning a different type of result. If you then try to invoke item
on an id
typed pointer, there's no way to know what the result type is supposed to be.
That's what XCode is lamenting about.
How to solve it depends a lot on what are you really are trying to do. Probably using different names for the methods is the best solution.
回答2:
If you have a method namespace collision occur, as in Analog File's post - invoking on an id pointer, you can resolve the "Multiple methods named.." error by casting the pointer to an acceptable class type.
So, presuming your original (error provoking) call was something like:
id myPointer = /* ... */;
[myPointer item];
You can command+click on "item" which will display the multiple classes XCode can send that message to. Cast to one of those classes so XCode knows which one to use, to something like:
[(UIActivityItemProvider*)myPointer item];