swarm-support
[Top][All Lists]
Advanced

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

Re: Arrays as arguments ?


From: Sven N. Thommesen
Subject: Re: Arrays as arguments ?
Date: Tue, 01 Jul 1997 18:39:34 -0500

Thanks to Ginger, Dwight and Casey for helpful hints.

I'm convinced whoever decided on the syntax for C pointer and array
declarations must have been on a bad acid trip at the time!

Here's what I ended up doing:

a) I declared these typedefs:

typedef short int valueLine [MAX2];
typedef valueLine *valueLinePointer;

typedef valueLine valueArray [MAX1]; or the equivalent:
   typedef short int valueArray [MAX1] [MAX2];
typedef valueArray *valueArrayPointer;

b) I could then define an instance var in an object:

valueArray myValueArray;

c) I defined a method 
-(valueArrayPointer) getValues;
which returns &(myValueArray);

d) I defined a method
-setValues: (valueArrayPointer) p;
which does this:
   myValueArray[i][j] = (*p)[i][j]; 
/* do NOT forget the parentheses around *p ! */

That solved the problem of passing multidimensional arrays as arguments. :-)

--Sven



At 10:15 AM 7/1/97 -0500, you wrote:
>I'm sure someone out there has already done this:
>
>I have an object which has an instance variable defined thus:
>
>short int myArr [MAX1] [MAX2];
>
>Given the limitations placed by ObjectiveC on the types of arguments that
>can be passed via messages, what is the best way to :
>
>a) pass an array like myArr as an argument to a message,
>b) pass such an array back as the return value of a message ?
>
>Sven


                  ==================================
   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]