Можно ли рисовать графику с помощью CGContext и сохранять ее в NSMutableArray?

Сначала я рисую графику:

    -(void)drawRect: (CGRect)rect{  

        //Circle
    circle = UIGraphicsGetCurrentContext();  
    CGContextSetFillColorWithColor(circle, [UIColor darkGrayColor].CGColor);
    CGContextFillRect(circle,CGRectMake(10,10, 50, 50));

        //rectangle
    rectangle = UIGraphicsGetCurrentContext();  
    CGContextSetFillColorWithColor(rectangle, [UIColor darkGrayColor].CGColor);
    CGContextFillRect(rectangle, CGRectMake(10, 10, 50, 50));

        //square 
    square = UIGraphicsGetCurrentContext();  
    CGContextSetFillColorWithColor(square, [UIColor darkGrayColor].CGColor);
    CGContextFillRect(square, CGRectMake(100, 100, 25, 25));

        //triangle  
    triangle = UIGraphicsGetCurrentContext(); 
    CGContextSetFillColorWithColor(triangle, [UIColor darkGrayColor].CGColor);
    CGPoint points[6] = { CGPointMake(100, 200), CGPointMake(150, 250),
                              CGPointMake(150, 250), CGPointMake(50, 250),
                              CGPointMake(50, 250), CGPointMake(100, 200) };
    CGContextStrokeLineSegments(triangle, points, 6);

    }

А теперь хочу поместить графику в массив:

-(void)viewDidLoad {

grafics = [[NSMutableArray alloc]initWithObjects: circle,rectangle,square,triangle];
[self.navigationItem.title = @"Shape"];
[super viewDidLoad];
}

Проблема в том, что мне нужно сделать приведение тем самым объекты помещаются в этот массив.Еще проблема в том что UITableViewController не загружает массив в строки.В табличном представлении нет ничего плохого,но сбой с обработкой CGContext.Что я делаю не так?

0
задан zoul 4 June 2012 в 08:23
поделиться