Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

swift

I am just going to new in swift,

I have one button on click of which opening front camera of iPad and clicking the photo of user, and when clicked on use photo,

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

is getting called of imagePickerController

this is the 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 submit it shows found nil value, after debugging 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 am not getting what I am doing wrong. as I am not good in swift, can any one please guide me for the same. I am stuck at this point.

Thanks in advance.

like image 636
Sagar Avatar asked Jun 13 '16 11:06

Sagar


1 Answers

I got the solution, Thanks to my colleague,

I am capturing the image from imagePickerController and getting saved in NSData. But the image captured it around 6-7 MB (iPad camera captures the image with this size by default) and when saving it into NSData and then converting it into base64 format goes out of size and then compiler throws the issue.

Issue solved just by changing in 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)
}
like image 126
Sagar Avatar answered Oct 20 '22 17:10

Sagar