0

Hi I am looking for some tutorials on using NSFileManager to store data in the directories such as cache and such, I havent really been able to find a good one with any nice examples. Any recommendations on where to find some? Thanks. ps. I know there is core Data too but at the moment I am just interested in finding one for NSFileManager

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178
Terrel Gibson
  • 481
  • 1
  • 6
  • 21
  • 1
    NSFileManager is used to create folders, delete files, move things... basically very high level file actions. But *not* the raw reading / writing of a file. What exactly are you trying to do? Save off cache data? – Michael Dautermann Aug 13 '12 at 22:55
  • I have an app that displays some photos and I want to cache the seen photos so that I dont have to redownload the photos that have already been viewed – Terrel Gibson Aug 13 '12 at 23:10

1 Answers1

0

I have an app that displays some photos and I want to cache the seen photos so that I dont have to redownload the photos that have already been viewed

see NSURLCache

Class Overview:

NSURLCache implements the caching of responses to URL load
requests by mapping NSURLRequest objects to NSCachedURLResponse
objects. It is a composite of an in-memory and an on-disk cache.

Methods are provided to manipulate the sizes of each of these
caches as well as to control the path on disk to use for persistent
storage of cache data.
justin
  • 104,054
  • 14
  • 179
  • 226
  • cmon... you've been around here long enough to know a good answer needs more substantial info than this. – Michael Dautermann Aug 13 '12 at 23:17
  • any tutorieals for using NSURLCache? – Terrel Gibson Aug 13 '12 at 23:21
  • I don't think NSURLCache is necessarily what you need, @Terrel. NSURLCache maps NSURLRequests to NSCachedURLResponse objects, whereas you are talking about figuring out which photos have been "already seen" versus ones not seen (and how are they loaded? from a remote server or from the on-device camera roll and the CPU-intensive AVAsset enumeration blocks?). – Michael Dautermann Aug 13 '12 at 23:22
  • @MichaelDautermann given the objective and the problem, yeah - i think "you're looking in the wrong place - look here instead" has enough substance. – justin Aug 13 '12 at 23:26
  • @TerrelGibson have you reviewed Apple's sample code, tutorials (e.g. URL Loading System Programming Guide) or googled? a few minutes after learning about the class seems too early (IMO) to imply you have exhausted what is clearly visible. – justin Aug 13 '12 at 23:28
  • @MichaelDautermann the objective is quoted in the answer, taken from the comments -- it is photos which are being downloaded multiple times. – justin Aug 13 '12 at 23:29
  • The photos are downloaded online from Flickr using API, I am doing the stanford courses and following the assignments, Assignment number 5 in this link says exactly what I am looking for. http://www.stanford.edu/class/cs193p/cgi-bin/drupal/downloads-2011-fall – Terrel Gibson Aug 13 '12 at 23:52