quartz core - How do I get this line to draw at the correct time and place

Why this code isn't being executed correctly. I have tried setNeedsDisplay and setNeedsLayout but this code doesn't appear to be executed. Even when it does execute, it executes when its not supposed to and it executes it wrong meaning it draws the line in the wrong place and with random length. - (void)drawNW{NSLog(@"%f",x1);NSLog(@"%f",y1);CGContextSetStrokeColorWithColor(c, [UIColor blueColor].CGColor);CGContextSetLineWidth(c, 10.0);CGContextMoveToPoint(c, x1, y1);CGContextAddLineToPoint(c, -(sqrtf(2)/2)*length + x1, ((sqrtf(2)/2)*length...Read more