[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Protocol questions
From: |
Murali Nandula |
Subject: |
RE: Protocol questions |
Date: |
Fri, 7 Apr 2000 12:12:51 -0400 |
Following is a work around..
Recruiter:
-(int) doThis
{
printf("Error: superclass/interface method! \n")
exit(0);
return 0; // to satisfy the compiler
}
Type A:
- (int) doThis
{
// sub class
// do calculations
return <somenumber>;
}
Since TypeA overrides the Recruiter the appropriate method
is called from sub-class always. Ofcourse if you tried to
send the call to TypeB which doesnot override it will
throw error and exit!
-Murali
> -----Original Message-----
> From: Paul Johnson [mailto:address@hidden
> Sent: Friday, April 07, 2000 11:48 AM
> To: Swarm-support
> Subject: Protocol questions
>
>
> In a model, the inheritance structure is like this:
>
> Recruiter
> |
> |
> ___________
> | |
> typeA typeB
>
> To improve compile-time error checking, I declared a protocol
> "Recruiter" and both typeA and typeB adopt it, as in.
>
> @interface typeA: Recruiter <Recruiter>
>
> Here are my problems.
>
> 1. Suppose typeA and typeB do really different things for a method
> "doThis". I want the Recruiter object to be able to use that
> method to
> get something, say:
>
> value=[self doThis];
>
> So it gets whatever is appropriate for whatever type it is.
>
> In the Recruiter class, what do I put as the return of a method like
> this:
> -(int) doThis
> {
> [self subclassResponsibility: @selector(doThis)];
> return ???????;
> }
>
> 2. In the Recruiter class, many methods are implemented. Some methods
> are added in typeA that are not in typeB. When I have a typeA
> object, I
> want to use those methods, but programs won't compile. The compiler
> says the method is not in the protocol. I have to add these
> methods to
> the protocol to get the compiler to work.
>
>
> --
> Paul E. Johnson email: address@hidden
> Dept. of Political Science
> http://lark.cc.ukans.edu/~pauljohn
> University of Kansas Office: (785) 864-9086
> Lawrence, Kansas 66045 FAX: (785) 864-5700
>
> ==================================
> Swarm-Support is for discussion of the technical details of the day
> to day usage of Swarm. For list administration needs (esp.
> [un]subscribing), please send a message to <address@hidden>
> with "help" in the body of the message.
>
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.