swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] Selectors


From: Steve Jackson
Subject: Re: [Swarm-Support] Selectors
Date: Wed, 09 Jul 2003 07:53:18 -0700

Try something like this:

- setPayoff: (float *) p
{
    payoff = *p;
   return self;
}
float pay=10.1;
[group forEach: M(setPayoff:):  (void *) &pay ];

or

float*  pay;
 pay = (float *) [whateverZone alloc: sizeof(float)];
*pay = 10.1;
[group forEach: M(setPayoff:):  (void *) pay ];

Free up the memory allocation when you're done with pay:
[whateverZone free: pay];



Marcello wrote:

> Pardon me the frequency of my questions!
>
> I have a method in a class Agent:
>
> - setPayoff: (float) p {
>
> payoff=p;
>
> return self;
> }
>
> Now, in another class, I have a List of Agent called "group". I'd like
> to pass through the list and set the payoff as follows:
> float pay=10.1;
> [group forEach: M(setPayoff:): pay ];
>
> If I do that, I get
> gcc: incompatible type for argument 4 of indirect function call
>
> if I set
> [group forEach: M(setPayoff:): (id) pay ];
> id does not work either,
>
> it only works if :
> [group forEach: M(setPayoff:): (int) pay ];
>
> but then pay is always zero.
>
> Any help?
> thanks
> marcello
> --
> Marcello Gallucci (Ph.D)
> Department of Social Psychology
> Free University
> Van der Boechorststraat 1
> 1081 BT Amsterdam (NL)
> Tel. +31(0)20 4448846
> Fax  +31 (0)20 4448921
> _______________________________________________
> Support mailing list
> address@hidden
> http://www.swarm.org/mailman/listinfo/support



reply via email to

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