Reputation: 416
My app is Fetching CoreData strings and uiimages. I'm also capturing the camera's live feed and displaying it on a UIView. Randomly the device 'Lost Connection'. I have checked the memory and CPU Usage and nothing seems to be going wrong there.
I occasionally get these printout warnings
Received memory warning.
_BSMachError: (os/kern) invalid name (20)
_BSMachError: (os/kern) invalid name (15)
Communications error: { count = 1, contents = "XPCErrorDescription" => { length = 22, contents = "Connection interrupted" } }>
I've tried setting my Localization native development region in the Info.plist to United States as was widely suggested but not luck.
I'm running Xcode 9 BETA and iOS 10 on my testing device (iPod).
Upvotes: 0
Views: 400
Reputation: 416
The way I was taking the picture returned a very high quality image (1000's of pixels). So when I passed the image in prepareForSegue and saved it using Core Data it was overloading the device.
So I used this code to reduce the size of the image and that worked.
func resizeImage(image: UIImage, newWidth: CGFloat) -> UIImage {
let scale = newWidth / image.size.width
let newHeight = image.size.height * scale
UIGraphicsBeginImageContext(CGSize(width: newWidth, height: newHeight))
image.draw(in: CGRect(x: 0,y: 0,width: newWidth,height: newHeight))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage!
}
Upvotes: 1