Converting a CGRect to an NSValue in an Array and vice versa

Viewed 8322

I have an array, full of CGRects. That part is fine. The problem is when I go to retrieve the CGRects from the array, I'm getting weird errors. Check out my code.

NSArray *frameLocations = [NSArray arrayWithObjects:
                           [NSValue valueWithCGRect:CGRectMake(20, 20, 121, 124)],
                           [NSValue valueWithCGRect:CGRectMake(176, 20, 121, 124)],
                           nil];

Than I get the frame in a for loop, like this:

 CGRect *imageFrame = [[frameLocations objectAtIndex:i] CGRectValue];

I've tried a bunch of different variations, spreading that line out over multiple variables. But I can't seem to get it.

1 Answers
Related