ios - Where to store downloaded data in iPhone application? -
i have scenario in application need download mp3, pdf, text files using application.
how can download, , store, data using application?
nsstring *stringurl = @"http://www.somewhere.com/thefile.png"; nsurl *url = [nsurl urlwithstring:stringurl]; nsdata *urldata = [nsdata datawithcontentsofurl:url]; if ( urldata ) { nsarray*paths=nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *filepath = [nsstring stringwithformat:@"%@/%@", documentsdirectory,@"filename.png"]; [urldata writetofile:filepath atomically:yes]; }
you can store in document directory,below example store image .below link explained store audio video file
how download audio/video files internet , store in iphone app?
Comments
Post a Comment