swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Class versus Protocol usage?? (was Re: One problem, one distraction


From: Paul E. Johnson
Subject: Class versus Protocol usage?? (was Re: One problem, one distraction
Date: Wed, 03 Feb 1999 11:00:01 -0600

"Marcus G. Daniels" wrote:
> 
> >>>>> "PJ" == Paul E Johnson <address@hidden> writes:
> 
> PJ> ObserverSwarm.m:158: invalid use of non-lvalue array
> PJ> ObserverSwarm.m:158: invalid use of non-lvalue array make: ***
> PJ> [ObserverSwarm.o] Error 1
> 
> PJ> Why? Comment that out, this works fine.
> 
> SET_WINDOW_GEOMETRY_RECORD_NAME takes an instance variable, and stringifies
> the name from that.
> 
> PJ> The object drawing itself is Citizen and inside its
> PJ> drawSelfOn method there are calls like [r getXDimNumber] and [r
> PJ> getYDimNumber]. The compiler seems to think the object on which
> PJ> the Citizen is to draw is Object2dDisplay, rather than
> PJ> WhiteRaster, so I get these warnings
> 
> Where is getXDimNumber defined?
It is defined in the WhiteRaster class, and when the program runs the
method does get found. It just the compiler warnings that bug me. 

Looking at this made me realize that I still don't understand protocol
versus class in Swarm. The Next doc does not help much either.  

What can you say about this:

ZoomRaster is a protocol in Swarm, but to make a new Class WhiteRaster,
I treated ZoomRaster as if it were a class. The top of the interface
declaration is

#import <tkobjc/ZoomRaster.h>
@interface WhiteRaster: ZoomRaster {
      int XDimNumber, YDimNumber, spaceNumber;
  }

>From looking at the Next book on objective-c, I get the idea the
declaration ought to be something that has a class name where I have
ZoomRaster, and then follow that with <ZoomRaster>. So is ZoomRaster a
class instead of a protocol? What class name to put there, I've got no
clue, if I want to follow the Next book and write it as:

@interface WhiteRaster: someClassName <ZoomRaster> {
      int XDimNumber, YDimNumber, spaceNumber;
  }.

Also, it is correct that such an object inherits all protocols that
ZoomRaster conforms to?

Here's why this is important to me. I see your point about
SET_WINDOW_GEOMETRY_RECORD_NAME not doing what I want.  I will find a
better way to go at this, but my first thought was to use the protocol
WindowGeometryRecord, where there is this method:
- setWindowGeometryRecordName: (const char *)windowGeometryRecordName 

That way I can assign any name I want for the archiving.  I want to
assign a name because there are going to be rasters created, all named
"policyRaster" and added to a list, and there's no name change to
differentiate them.

But, the more I stared at it, I could not figure a way to alter my
interface declaration for WhiteRaster to make it also use the protocol
WindowGeometryRecord. (Incidentally, in the docs it says the name of the
protocol is WindowGeometryRecordName, but in the gui source directory, I
find it defined as WindowGeometryRecord, but this may just indicate I
don't understand what is a class and what is a protocol).  If I could
make WhiteRaster follow that protocol in addition to ZoomRaster, then I
could get the archived names I need.
-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (913) 864-9086
Lawrence, Kansas 66045                FAX: (913) 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]