<구조체(CGPoint,CGSize,CGRect) -> 객체(NSDictionary) -> 구조체>

사용 예)
- (void)sample {
    NSMutableArray *a = [NSMutableArray array];
    CGPoint p = CGPointMake(5.0, 6.0);
    NSDictionary *pointObject = [NSDictionary dictionaryWithCGPoint:p];
    [a addObject:pointObject];
    [a addObject:[NSDictionary dictionaryWithCGSize:CGSizeMake(50.0, 60.0)]];
    CGRect rect = CGRectMake(20.0, 40.0, 100.0, 60.0);
    [a addObject:[NSDictionary dictionaryWithCGRect:rect]];
    NSLog(@"%@",a);
 
    CGPoint point = [pointObject CGPointValue];
    CGSize size = [[a objectAtIndex:1] CGSizeValue];
    CGRect rect2 = [[a objectAtIndex:2] CGRectValue];
 
    NSLog(@"point: %f,%f",point.x,point.y);
    NSLog(@"size: %f,%f",size.width,size.height);
    NSLog(@"rect: %f,%f,%f,%f",rect2.origin.x,rect2.origin.y,rect2.size.width,rect2.size.height);
}


반응형