So i'm using AVFoundation to make a camera, but for some reason i keep getting this error when i go to capture, most of the time it results in my phone losing connection to Xcode and crashing the app, I also use it to crop images and get the same sort of error. Is anybody able to tell me why this error occurs?
Communications error: <OS_xpc_error: <error: 0x19b14ca80> { count = 1,
contents = "XPCErrorDescription" => <string: 0x19b14ce78> {
length = 22, contents = "Connection interrupted" } }>
Here is the code for the capture:
public func capturePictureWithCompletition(imageCompletition: (UIImage?, NSError?) -> Void) {
var blockHandler = { (imageDataSampleBuffer: CMSampleBuffer?, error: NSError?) -> Void in
if let imageDataSampleBuffer = imageDataSampleBuffer {
let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageDataSampleBuffer)
let image = UIImage(data: imageData)
imageCompletition(image?.normalizedImages, nil)
} else {
imageCompletition(nil, error)
}
}
if self.cameraIsSetup {
if self.cameraOutputMode == .StillImage {
if let stillImageOutput = self.stillImageOutput {
let connection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo)
stillImageOutput.captureStillImageAsynchronouslyFromConnection(connection, completionHandler: blockHandler)
}
}
}
}