Re: Multidimensional C arrays as OBJ-C method args: partial
Re: Multidimensional C arrays as OBJ-C method args: partial
- Subject: Re: Multidimensional C arrays as OBJ-C method args: partial
- From: Bob Savage <email@hidden>
- Date: Wed, 02 Jan 2002 21:52:34 -0600
Hi, Erik,
on 1/2/02 7:26 PM, Erik M. Buck wrote:
>
> -(void)setFloatValueByTotalingArrayPointer:(float *)theArray[];
>
>
>
Try -(void)setFloatValueByTotalingArrayPointer:(float *[])theArray;
>
>
or
>
>
typedef float *myArray_t[6];
>
-(void)setFloatValueByTotalingArrayPointer:(myArray_t)theArray;
>
>
or
>
>
-(void)setFloatValueByTotalingArrayPointer:(float [6][3])theArray;
>
>
or
>
>
typedef float *myArray_t[6][3];
>
-(void)setFloatValueByTotalingArrayPointer:(myArray_t)theArray;
>
>
I have not tried these myself yet, but I think they may work.
That was a bit of an understatement :) They all worked!
>
A quick look at the
>
grammar for Objective-C would probably clarify the issue.
Actually if you mean the "Reference Manual for the Objective-C Language"
(Appendix B, to the Obj-C book), no it doesn't describe what to do in this
situation at all.
Well, thanks to everyone that helped, now I can put this to use doing
something interesting!
Bob Savage
For anyone following in my footsteps (heaven help them!) you should note
that I also needed to make these changes to the implementations:
59,60c59,60
< printf("\t\tvalue of the array at slot [%d] = '%.3f'\n", i,
theArray[i*stride+j]);
< f+= theArray[i*stride+j];
---
>
printf( "\t\tvalue of the array at slot [%d] = '%.3f'\n", i,
theArray[i][j] );
>
f+= theArray[i][j];
70c70
< [self setFloatValueByTotalingArray:(theArray+i*stride)
ofSize:stride];
---
>
[self setFloatValueByTotalingArray:*(theArray+i) ofSize:stride];