The expression received an error: Execution was aborted, reason: go. This process was returned to the state before evaluating the expression.

I'm just going to new, fast,

I have one button that, when clicked, opens the front camera of the iPad, and by clicking on the user's photo, and when I click on use the photo

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) 

receives a call to imagePickerController

this is a line of code.

 func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { picker .dismissViewControllerAnimated(true, completion: nil) photoImgView.image=info[UIImagePickerControllerOriginalImage] as? UIImage if imageData == nil { imageData = UIImageJPEGRepresentation((info[UIImagePickerControllerOriginalImage] as? UIImage)!, 1) } } 

but when I send it, it found the nil value found, after debugging I got this point in func didFinishPickingMediaWithInfo which says

 (lldb) po imageData expression produced error: Execution was interrupted, reason: step over. The process has been returned to the state before expression evaluation. 

I do not understand what I am doing wrong. because I'm not very good at fast, can anyone guide me for the same. I am stuck at this point.

Thanks in advance.

+5
source share
2 answers

I got a solution, Thanks to my colleague,

I collect the image from imagePickerController and get the save in NSData . But the image captured it about 6-7 MB (the iPad camera captures the image with this default size) and when saving it to NSData , then converting it to base64 format goes beyond the size and then the compiler throws the problem.

The problem is solved simply by changing the line code for UIImageJPEGRepresentation

 func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { photoImgView.image=info[UIImagePickerControllerOriginalImage] as? UIImage imageData = UIImageJPEGRepresentation((info[UIImagePickerControllerOriginalImage] as? UIImage)!, 0.5) print(imageData) picker .dismissViewControllerAnimated(true, completion: nil) } 
+1
source

You call dissmissViewController(:_) at the beginning. Name it at the end of the function and try it.

0
source

All Articles