I am trying to achieve something similar and am too much of a newbie with generics and associated types to understand what is going on. Definitely following this.
Post
Replies
Boosts
Views
Activity
Hey Tillmoss,
I had the same error as you, I had copied some code from Hacking With Swift that I think was out of date. I then found the solution thanks to a YouTube video by the user Jared Davidson. It won't allow me to link to his video but the solution is to do the following :
import CoreImage.CIFilterBuiltins
let context = CIContext()
let filter = CIFilter.qrCodeGenerator()
...
private func generateQRCode(from string: String) - UIImage {
let data = Data(string.utf8)
filter.setValue(data, forKey: "inputMessage")
if let qrCodeImage = filter.outputImage {
if let qrCodeCGImage = context.createCGImage(qrCodeImage, from: qrCodeImage.extent) {
return UIImage(cgImage: qrCodeCGImage)
}
}
return UIImage(systemName: "xmark") ?? UIImage()
}