UIGraphicsGetCurrentContext threading problem
The reference says this: "You should call this function from the main thread of your application only."
But I would like to get the current graphics context from separate threads. What do you think? What can I do to reach this?Edit: Thanks guys for the answers. I don't know which is good for me at the moment, but t开发者_高级运维hank you very much.
Never draw to the screen from anything other than the main thread!!! The graphics chip is single threaded, so you could cause all kinds of race conditions if you don't follow that rule.
You can draw to a background NSImage and then notify the main thread when you're finished and to update the screen.
If you want to draw from other threads, either create your own CGBitmapContext or use a CATiledLayer.
I would say restructure your logic to conform to the reference's advice.
Generally it is accurate about things you should and shouldn't do.
Why do you want to access it from different threads?
精彩评论