swarm-support
[Top][All Lists]
Advanced

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

Re: newbish question


From: Scott Christley
Subject: Re: newbish question
Date: Wed, 3 Dec 1997 13:54:39 -0800

Hmm, not exactly clear what you are trying to do but I will take a guess.

At 02:39 PM 12/3/97 -0500, address@hidden wrote:
>Hi,
>Can agents access each other with casting?

Yes, but it is generally better to use accessor methods; i.e. methods for
retrieving and setting the variables.

You can make an ObjC classes variables public, so that you can access them
as though it was a C structure.

@interface ToBeOwned
{
@public
  int x;
  int y;
}
@end

main()
{
  id anObj = [[ToBeOwned alloc] init];

  ((ToBeOwned *)anObj)->x = 5;
  ((ToBeOwned *)anObj)->y = 100;
}

Am I close to what you are looking for?

Scott


>
>Heres what I want to do:
>I have two types of agents, "owners" and "to-be-owned".
>The "to-be-owned" agents are only 8 in number, and have a defined type
>called TypeType which is just integers from 1 to 8.  There is only one
>of each agent.  I want to be able to pass a int to the owner agent, and
>then be able to have the owner access the "to-be-owned" variables
>(etc)...
>
>It seems like this would be pretty straightforward, but I can't seem to
>figure it out...[frown].
>
>(background info), I am using graph library stuff, and the owner agents
>will "point" to each "to-be-owned" agent (which it owns).  Multiple
>owners can own each "to-be-owned" agents. 
>
>Thanks,
>Brad.
>
>                  ==================================
>   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.
                  ==================================


reply via email to

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