CGPoint à NSValue et inverser
J'ai code:
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
est CGPoint, j'ai donc besoin en quelque sorte de changer de CGPoint à NSValue pour l'ajouter à NSMutableArray et après que le reconvertir en CGPoint. Comment pourrait-il être fait?
source d'informationauteur hockeyman
Vous devez vous connecter pour publier un commentaire.
La classe
NSValue
a des méthodes+[valueWithPoint:]
et-[CGPointValue]
? Est-ce ce que vous recherchez?