core data - ios save Image Offline -



core data - ios save Image Offline -

i have application receive images webservices , show them in list illustration film theatre schedule

my question : possible store images in core info or else can show them when user not connected net ?

yes can.

// save image disk nsstring *documentarypath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; nsstring *filepath = [nsstring stringwithformat:@"%@/image.png",documentarypath]; nsdata *data = [nsdata datawithdata:uiimagepngrepresentation(your_image)]; [data writetofile:filepath atomically:yes]; // retrieve image - (nsdata *) imagedata { nsstring *docdir = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; nsstring *pngfilepath = [nsstring stringwithformat:@"%@/image.png",docdir]; nsdata *dataimage = [nsdata datawithcontentsoffile:pngfilepath]; homecoming dataimage; }

and later

uiimage *image = [uiimage imagewithdata:imagedata]

ios core-data uiimageview

Comments

Popular posts from this blog

php - How to pass multiple values from url -

database - php search bar when I press submit with nothing in the search bar it shows all the data -

ios - How to load .png images from Documents folder of an app -