The filtering on the photo works but I'm stuck with this problem.
let originalImage = CIImage(image: imageView.image)
var filter = CIFilter(name: "CIPhotoEffectMono")
filter.setDefaults()
filter.setValue(originalImage, forKey: kCIInputImageKey)
var newImage = UIImage(CIImage: filter.outputImage)
imageView.image = newImage
BSXPCMessage received error for message: Connection interrupted
fatal error: unexpectedly found nil while unwrapping an Optional value
Then the app crashes.
How would I fix it and the errors?
Updated
let originalImage = CIImage(image: imageView.image)
var filter = CIFilter(name: "CIPhotoEffectMono")
filter.setValue(originalImage, forKey: kCIInputImageKey)
let context = CIContext(options: [kCIContextUseSoftwareRenderer: true])
let outputImage = context.createCGImage(filter.outputImage, fromRect: filter.outputImage.extent())
var newImage = UIImage(CGImage: outputImage)
imageView.image = newImage
*Based on Lamar's code.
CIContext(options: nil)
was causing BSXPCMessage received error for message: Connection interrupted
error.
SO replace:
CIContext(options: nil)
with CIContext(options: [kCIContextUseSoftwareRenderer: true])
Thanks For The Help:
Lamar
The app doesn't crash anymore.