Defeating the "multiple methods named 'xxx:' found" error
Solution 1
Make sure [connection writer] is actually returning a TCPWriter*. If it is returning an id, then the compiler will not know which writeData to use. Also, make sure you are importing the TCPWriter.h file - if the compiler does not see the header files, it will default to returning id, which will get you back to the same problem.
Try
TCPWriter* writer = [connection writer];
[writer writeData: data];
or
[(TCPWriter*)[connection writer] writeData: data];
Solution 2
As an alternative to the splendid answer above, you can cast the object to the right type to get rid of the warning too, like so:
[(NSView*)textView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; // for horizontal scrolling
Brian
I here to kick butt and code software. I'm all out of butt.
Updated on January 06, 2020Comments
-
Brian over 4 years
In my current project inside the file ViewController.m, I am running the method:
[[connection writer] writeData: data];
It returns the warning:
warning: multiple methods named 'writeData:' found
I am attempting to call the method:
- (void) writeData: (NSData*)data
...in TCPWriter.m. Unfortunately, there are two other
writeData
methods- (void)writeData:(NSData *)data;
...in NSFileHandle.h and...
- (BOOL)writeData:(NSData *)data
...in NSURLHandle.h. This is especially confusing to me because
[conn writer]
should return theTCPWriter
class and that class should call the correctwriteData
method. Furthermore, I am not even completely sure that NSFileHandle.h and NSURLHandle.h are even included in any of the libraries included in ViewController.h, rather than in a different part of the project.How can I show the compiler which
writeData
method I want to call and why does this error happen?