我成功地从URL服务器加载了plist,但是缓存保存了旧数据。这是加载plist的代码,如何实现NSURLRequest清除旧的缓存数据?还是我需要尝试另一种方法?
这个问题部分回答了这个问题: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];