Alex Rivera | Logout

How to store CGRect values in NSMutableArray?

Asked 2010-05-29T07:17:28.707
114

How would I store CGRect objects in a NSMutableArray, and then later retrieve them?

Edit
Report

1 Answer

294

You need to wrap the CG structures in NSValue classes. So:

NSMutableArray* array = [NSMutableArray mutableArray];
[array addObject:[NSValue valueWithCGRect:CGRectMake(0,0,10,10)]];
CGRect someRect = [[array objectAtIndex:0] CGRectValue];
answered 2010-05-29T07:22:53.873

Your Answer