🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1042

Re: Multiple init: functions defined

#1042
From: jim Jim Mackraz
Date: Thu, 03 Sep 1992 00:02
52 lines
1793 bytes
Jack Gidding writes
> 
> Hmmmm..... this is really strange and very undesired behavior from  
Objective-C.
> 
> When I include the header files from two different classes into a third  
class,  
> and each of the included classes have a single init: method defined, I get  
> messages similar to the following:
> 
> 
> main2.m:18: warning: multiple declarations for method `init:'
> /Clib/RP.h:32: using `-init:(int )pSize'
> /Clib/RS.h:31: also found `-init:(OBJPTR )s'
> 
> 
> Why is this happening??? Sometimes it tells me that it resolved which init to  
> use, sometimes not, and sometimes it resolves it to the wrong init:.
> 
> 
> The code that has the init method is sililar in form to:
> 
> 	#import <RP.h>	// Both RP and RS have and init: method
> 	#import <RS.h>
> 
> 	id x;
> 
> 	x = [[RP alloc] init:(int) 5];
> 
> id is totally dynamic, and thus it really does not know which init to use....
> 
> So, why is it telling me that it is using one method or another...shouldn't  
> this be left up until run-time? 
> 
> 
> Am I doing something wrong to cause this?

Yeah, you're "type overloading" the method "init:".  Don't do that.
Make one of the "-initInt: (int) intVal" and the other one
 "-initObj: (OBJPTR) obj"

... or something like that.


> Thanks,
> 
> 
> Jack Gidding
> jack@richsun.cpg.trs.reuter.com
-- 
Jim Mackraz
jim@oceania.com
Technical Details
Message-ID: <Btz6sL.8qC@oceania.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!oceania!jim
References: <3575@richsun.cpg.trs.reuter.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!oceania!jim
From: jim (Jim Mackraz)
Subject: Re: Multiple init: functions defined
Message-ID: <Btz6sL.8qC@oceania.com>
Sender: jim@oceania.com (Jim Mackraz)
Reply-To: jim@oceania.com
Organization: Oceania Health Care Systems
References: <3575@richsun.cpg.trs.reuter.com>
Date: Thu, 3 Sep 1992 00:02:43 GMT
Lines: 52