Ahoura Ghotbi
Ahoura Ghotbi

Reputation: 2896

NSLog an array of CGPoints

I have declared the following CGPoint :

CGPoint borderVertices[5000];

I have added all the values to the array if I may call it (or just a set), but now I was wondering if there is anyway I can NSLog these points or copy them to a file.

I have tried :

NSLog(@"vertices %@", NSStringFromCGPoint(borderVertices));

but I get an error.

Upvotes: 0

Views: 1102

Answers (3)

Gabriel
Gabriel

Reputation: 3045

You could make an array like:

CGPoint borderVertices[5000];
float bVx[5000];
float bVy[5000];

And assign values to bVx and bVy with borderVertices.position.(x or y) in a loop and then whenever you need the coordinates... there you have it.

Upvotes: 1

Jef
Jef

Reputation: 2134

What about:

for (NSUInteger i = 0; i < 5000; i++)
{
   NSLog(@"vertices :%@", NSStringFromCGPoint(borderVertices[i]));
}

Upvotes: 4

Mahesh
Mahesh

Reputation: 34625

Arrays like in plain old c, needs to be iterated to print each value at it's index.

NSLog(@"vertices %@", NSStringFromCGPoint(borderVertices));

The above statement would have worked if borderVertices is of type CGPoint. But it is not, it is of type CGPoint[].

Upvotes: 1

Related Questions