title: Dynamically allocating length to an objective C static array
body: <p>Hi I am relatively new to programming on iOS and using objective C. Recently I have come across an issue I cannot seem to solve, I am writing a OBJ model loader to use within my iOS programming. For this I use two arrays as below: </p>
  
  <pre><code>static CGFloat modelVertices[360*9]={};
  static CGFloat modelColours[360*12]={}; 
  </code></pre>
  
  <p>As can be seen the length is currently allocated with a hard coded value of 360 (the number of faces in a particular model). Is there no way this can be dynamically allocated from a value that has been calculated after reading the OBJ file as is done below?</p>
  
  <pre><code>int numOfVertices = //whatever this is read from file;
  static CGFloat modelColours[numOfVertices*12]={}; 
  </code></pre>
  
  <p>I have tried using NSMutable arrays but found these difficult to use as when it comes to actually drawing the mesh gathered I need to use this code:</p>
  
  <pre><code>-(void)render
  {
  // load arrays into the engine
  glVertexPointer(vertexStride, GL_FLOAT, 0, vertexes);
  glEnableClientState(GL_VERTEX_ARRAY);
  glColorPointer(colorStride, GL_FLOAT, 0, colors);   
  glEnableClientState(GL_COLOR_ARRAY);
  
  //render
  glDrawArrays(renderStyle, 0, vertexCount);  
  }
  </code></pre>
  
  <p>As you can see the command glVertexPointer requires the values as a CGFloat array:</p>
  
  <pre><code>glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
  </code></pre>