I'm editing some CGImage
s and strangely enough until now I was first creating NSImage
s from those CGImage
s before drawing them. So I tried to change the code so that I would draw the CGImage
s directly in into NSGraphicsContext.currentContext().graphicsPort
. As you see I'm using Swift here but the same problem goes for Objective-C I presume.
Having a look into the documentation I saw that graphicsPort
will be deprecated in 10.10, but I couldn't find another way to the current CGContext
from NSGraphicsContext
nor is there a way to create the CGContext
from an NSGraphicsContext
.
Does anybody know what the proper way to retrieve the context would be? If not - Is there a way to cast the graphicsPort
's COpaquePointer
, which apparently is an initialized NSPipe
Object, to a CGContextRef
? Although using code that has already been marked deprecated would be quite unsatisfactory I would consider it until there is a better solution.
After spending a half hour digging around for information on this, I realized I should just check out the header file for NSGraphicsContext
. Turns out there's a new property on NSGraphicsContext
that's apparently not documented yet: CGContext
. The header also notes that this should be used instead of graphicsPort
.