CGPoint para NSValue e reverso
Eu tenho código:
NSMutableArray *vertices = [[NSMutableArray alloc] init];
//Getting mouse coordinates
loc = [self convertPoint: [event locationInWindow] fromView:self];
[vertices addObject:loc]; // Adding coordinates to NSMutableArray
//Converting from NSMutableArray to GLfloat to work with OpenGL
int count = [vertices count] * 2; // * 2 for the two coordinates of a loc object
GLFloat []glVertices = (GLFloat *)malloc(count * sizeof(GLFloat));
int currIndex = 0;
for (YourLocObject *loc in vertices) {
glVertices[currIndex++] = loc.x;
glVertices[currIndex++] = loc.y;
}
loc
é CGPoint, então eu preciso de alguma forma para mudar de CGPoint para NSValue para adicioná-lo ao NSMutableArray e depois convertê-lo de volta para CGPoint. Como poderia ser feito?