How would I store CGRect objects in a NSMutableArray, and then later retrieve them?
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];
CGRect rect = CGRectMake( 5, 5, 40, 30 ); NSString* rectAsString = NSStringFromCGRect( rect ); CGRect original = CGRectFromString( rectAsString );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With