0

I successfully load plist from URL server, but cache holds old data. Here is my code to load plist, how can I implement NSURLRequest to clear old cache data? Or do I need to try another approach?

This question partially answer this problem: https://stackoverflow.com/questions/11235883/downloading-plist-but-seem-to-get-a-cached-version-every-time#=

NSString *stringURL = @"https://web.com/myPlist.plist";

NSURL  *url = [NSURL URLWithString:stringURL];
NSData *urlData = [NSData dataWithContentsOfURL:url];
NSArray   *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString  *documentsDirectory = [paths objectAtIndex:0];
NSString  *plistPath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"myPlist.plist"];
[urlData writeToFile:plistPath atomically:YES];
halfer
  • 19,471
  • 17
  • 87
  • 173
magero
  • 71
  • 11

0 Answers0