Re: Method declaration conflict with NSURLConnection.
Re: Method declaration conflict with NSURLConnection.
- Subject: Re: Method declaration conflict with NSURLConnection.
- From: "Louis C. Sacha" <email@hidden>
- Date: Thu, 12 Feb 2004 00:00:37 -0800
Hello...
You will probably want to change your intializer so that the selector
is different.
The issue is that alloc always returns type id, so when you do nested
message like [[YourClassName alloc] initWithRequest:request
delegate:delegate] the initializer is always being sent to an object
of type id (and the compiler doesn't know if the id points to a
NSURLConnection or an instance of your class.
If you don't change the initializer, every time someone wants to
create an instance of your class, they will have to statically type
the object returned from alloc:
YourClassName *object = [(YourClassName *)[YourClassName
alloc] initWithRequest:request delegate:delegate];
You would probably be much better off making a slight change in the
selector ***, maybe like
- (id)initWithXMLRPCRequest:(XMLRPCRequest *)request delegate:(id)delegate;
For more info, see the Archives:
"Multiple declarations for method length"
http://cocoa.mamasam.com/COCOADEV/2003/12/2/80393.php
"Warning when using NSSplitView"
(aka "Warning when using NSSplitView (multiple declerations for
method 'isVertical'")
http://cocoa.mamasam.com/COCOADEV/2004/01/1/80671.php
Hope that helps,
Louis
*** Technically it might be possible to redeclare +alloc in your
classes header file to return (YourClassName *) instead of (id), but
the convention is to always return id from alloc and initializers,
and there's a possibility that doing so could cause even worse / more
annoying problems. Perhaps someone else on the list will be able to
tell you for sure...
I'm writing an XML-RPC framework that follows a request, connection,
response pattern. The developer creates the request, supplies a connection
with a request, then returns a response. A lot of the inner workings of
these classes rely on the NSURLRequest and NSURLConnection classes. All is
fine until, however, I create an instance of my connection class. It just so
happens that my connection class and the NSURLConnection class have the same
init method, with slight differences...
- (id)initWithRequest: (XMLRPCRequest *)request delegate: (id)delegate;
I wouldn't think this should be a problem, but it is. When I write code that
uses this class, and initializes it, the compiler thinks I am making a call
to NSURLConnection's method, not my own. A strange behavior, considering
everything has been declared properly, and I'm not doing anything crazy. I
don't know what the problem could be, any ideas?
Regards,
Eric Czarny
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.