“fatal error: unexpectedly found nil while unwrapping an Optional value” while using vImageBuffer_initWithCGImage in Swift ios
问题 I'm working in Swift iOS8 and trying to convert UIImage to vImage_Buffer to perform manipulations using Accelerate.framework. I'm trying to use vImageBuffer_initWithCGImage for conversion, here is the code that I tried: func initvImageBufferwithUIImage (image:UIImage)-> vImage_Buffer{ var CGImg:CGImageRef = sunset.CGImage var inProvider:CGDataProviderRef = CGImageGetDataProvider(CGImg) var inBitmapData:CFDataRef = CGDataProviderCopyData(inProvider) var buffer:vImage_Buffer! var format:vImage