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

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

SQL Server : need assitance parsing delimted data and returning a long concatenated string -