title: Xcode / iOS: Simple example of a mutable C-Array as a class instance variable?
body: <p>For some reason I just cant seem to get my head around the process of creating a C-Array instance variable for a class that can have elements added to it dynamically at runtime.</p>
  
  <p>My goal is to create a class called <code>AEMesh</code>. All <code>AEMesh</code> objects will have a c-array storing the vertexdata for that specific <code>AEMesh</code>'s 3D model for use with OpenGL ES (more specifically it's functionality for drawing a model by passing it a simple C-Array of vertexdata).</p>
  
  <p>Initially I was using an <code>NSMutableArray</code>, on the assumption that I could simply pass this array to OpenGL ES, however that isnt the case as the framework requires a C-Array. I got around the issue by essentially creating a C-Array of all of the vertexdata for the current <code>AEMesh</code> when it came time to render that specific mesh, and passing that array to OpenGL ES. Obviously the issue here is performance as I am constantly allocating and deallocating enough memory to hold every 3D model's vertexdata in the app about a dozen times a second.</p>
  
  <p>So, Im not one to want the answer spoon fed to me, but if anyone would be willing to explain to me the standard idiom for giving a class a mutable c-array (some articles Ive read mention using <code>malloc</code>?) I would greatly appreciate it. From the information Ive gathered, using malloc might work, but this isn't creating a standard c-array I can pass in to OpenGL ES, instead its more of a pseudo-c-array that works like a c-array?</p>
  
  <p>Anyways, I will continue to experiment and search the internet but again, if anyone can offer a helping hand I would greatly appreciate it.</p>
  
  <p>Thanks, 
  - Adam Eisfeld</p>