0

I don't want to use NSUserDefaults, so how do I save an image in core data then retrieve it?

My image is in this variable.

var image:UIIMage = image1

Can you please give me some sample code to do this?

icodebuster
  • 8,890
  • 7
  • 62
  • 65
nachshon f
  • 3,540
  • 7
  • 35
  • 67

3 Answers3

2

UIImage -> NSData

NSData *imageData = UIImagePNGRepresentation(image); or  UIImageJpegRepresentation(image)

NSData -> UIImage

UIImage *image=[UIImage imageWithData:data];
1

Convert UIImage into NSData and save as the entity's attribute with the type Binary Data

duan
  • 8,515
  • 3
  • 48
  • 70
0

this question is already answered by stack-overflow refer this

How to store an image in core data

Community
  • 1
  • 1
Rizwan Shaikh
  • 2,824
  • 2
  • 27
  • 49