Comment stocker les valeurs CGRect dans NSMutableArray?

Comment stocker les objects CGRect dans un NSMutableArray, puis les récupérer ultérieurement?

Vous devez envelopper les structures CG dans les classes NSValue . Alors:

 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 ); NSSsortingng* rectAsSsortingng = NSSsortingngFromCGRect( rect ); CGRect original = CGRectFromSsortingng( rectAsSsortingng ); 

Que pensez-vous de cette façon de stocker les dates de CGRect?

Nous stockons les CGRect , CGPoint , CMTime dans un NSMutableArray ,

[arrayName addObject:[NSValue valueWithCGPoint:MyCGPoint]]

[arrayName addObject:[NSValue valueWithCGRect:MyCGRect]]

[arrayName addObject:[NSValue valueWithCMTime:MyCMTime]]

[arrayName addObject:[NSValue valueWithCMTimeRange:MyCMTimeRange]]

 Store ssortingng in array.and then get back ssortingng and convert that in CGRect back as per the need. CGRect rect = CGRectMake( 5, 5, 40, 30 ); NSSsortingng* rectAsSsortingng = NSSsortingngFromCGRect( rect ); NSMutableArray* array = [NSMutableArray mutableArray]; [array addObject:rectAsSsortingng]; For converting ssortingng in CGRect back use:- CGRect rect9 = CGRectFromSsortingng(rectAsSsortingng);