0

I have a database with images stored as blobs and would like to display them in a UiImage. I am able to get the data into my app as a JSON feed and I am able to grab the image data (via print) as follows

[["image": <UIImage: 0x14ea397b0> size {750, 750} orientation 0 scale 1.000000]]

I have no idea how I translate this data back into the UIImage I have on my storyboard

1 Answer 1

1

suppose you have blob data as a string from db. you can convert it to image as bellow.

let imageBytes = "" // blob data
DispatchQueue.main.async {
    if let imgData = imageBytes.dataUsingEncoding(NSUTF8StringEncoding){
        self.imageView.image = UIImage(data: imgData)
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.