0

I got following troubling problem: I want to transfer a CGImage from Swift into Objective C. It just doesn't work

That's the call

func transferImage(cgImage: CGImage) {
objcobject.cgimage = cgImage
}

That's the objc header:

@property (nonatomic, assign) CGImageRef *cgimage;

This gives my the build time error: "Cannot assign value of type 'CGImage' to type 'UnsafeMutablePointer?>?'"

Does anybody know how to get a CGImage safely and properly from swift into objective c? CGImage doesn't work, CGImageRef doesn't work. I'm pretty desperate!

Martina
  • 11
  • 3
    This is a very unusual ObjC interface. It is strange, and likely a mistake, to have a pointer to a ...Ref type (Ref types are already references). The fact that it's marked `assign` is also somewhat concerning (though it may be correct). Where did this ObjC code come from? Are you certain that the ObjC is correct? – Rob Napier Feb 07 '19 at 15:34
  • Thanks for the answer <3, just didn't fully understand the concept of CGImageRef :/ – Martina Feb 08 '19 at 09:11

0 Answers0