return pointer to a 2d aray

  • Hi List,

    On a related question to my last one, how do you return a pointer to a
    2d array from an object's method?  For example, the class below
    contains an instance variable that is a 2d array.

    Thanks,

    - Jason

    // MyClass.h
    @interface MyClass : NSObject {
    uint16_t pixels[480][640];
    }

    - (uint16_t **)pixels;     // What goes here?  This isn't right, I've
    tried it.
    @end

    // MyClass.m
    @implementation Image

    - (uint16_t **)pixels     // And what goes here?
    {
    return pixels;
    }

    @end
  • Jason,

    You have to change your method return type to uint16_t *.  If you need
    the return type to be uint16_t ** then you would need to change your
    internal representation, perhaps adding the following instance variable

        uint16_t **rows;

    and initializing it as described earlier today.

    dave

    On 12-Nov-07, at 3:28 PM, Jason Horn wrote:

    > Hi List,
    >
    > On a related question to my last one, how do you return a pointer to
    > a 2d array from an object's method?  For example, the class below
    > contains an instance variable that is a 2d array.
    >
    > Thanks,
    >
    > - Jason
    >
    >
    > // MyClass.h
    > @interface MyClass : NSObject {
    > uint16_t pixels[480][640];
    > }
    >
    > - (uint16_t **)pixels;     // What goes here?  This isn't right, I've
    > tried it.
    > @end
    >
    >
    >
    > // MyClass.m
    > @implementation Image
    >
    > - (uint16_t **)pixels     // And what goes here?
    > {
    > return pixels;
    > }
    >
    > @end
    >
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today