我会很简短:
我正在使用 drawrect 和 NSBezierPath 绘制线条。
为了画出这些线条,我使用了一个 for 循环。
现在,由于循环需要很多秒,我正在尝试使用 NSProgresIndicator 来显示进度并在我使用 dispatch_async & queue 的循环中更新它。ProgressIndicator 更新但没有绘制任何内容。如果不使用队列绘制了线条,但指标在周期结束时更新。
我究竟做错了什么 ?
错误:
<Error>: CGContextRestoreGState: invalid context 0x0.
This is a serious error.
This application, or a library it uses, is using an invalid context
and is thereby
contributing to an overall degradation of system stability and reliability.
This notice is a courtesy: please fix this problem.
It will become a fatal error in an upcoming update.
// SAMPLE OF CODE
dispatch_queue_t myQueue = dispatch_queue_create("my queue", NULL);
dispatch_async(myQueue, ^
{
for (int i = 1; i <= 200; i++) {
dispatch_async(dispatch_get_main_queue(), ^{
[istance set_progress:i];
//This sets the progress, but bezierPath doesn't work
});
//Bezier already alloc & init
[my_path moveToPoint....]
[my_path lineToPoint....]
[my_path stroke]
}
});