Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multidimensional C array as method parameter (OBJ-C)



Hi,

I am trying to use Cocoa (Obj-C) and OpenGL together. To create some vertex
lists I was hoping I could bypass the conversion to/from strings by NSPoints
(NSStringFromPoint) and etc. that is involved in passing arrays of NSPoints
around. I will be using quite a lot of points, and converting them between
an internal coordinate system (a hexagonal space) and the standard cartesion
coordinate system for display via OpenGL. I thought keeping everything in a
multidimensional C array as much as possible would make it easier for me
when I declare the GL vertex array.

I can easily pass a one dimensional array of NSPoints (using type
"NSPointArray"), in fact I use that to calculate the vertices of the hexagon
from a center.

I COULD create a function which accepts a multidimensional array, ( by
declaring the parameter like this: "NSPoint pArray[][6]" ) but then I lose
the benefits of OBJ-C (e.g. access to the class' namespace -- iVars, "self"
etc.

Unfortunately the compiler considers using a construct like
"funcName:(NSPoint)pARRAY[][6]" an illegal method declaration. It will
compile using "funcName:(NSPointArray *)pARRAY", but then it doesn't know
how to do the pointer arithmetic within the function.

Sorry if I'm not being clear, I'm feeling a bit under the weather today, and
it seems to be affecting my communication skills.

best to all,

Bob Savage




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.