ios - NSXML解析器缓存

标签 ios caching

我正在开发一个使用 xml 解析的应用程序。一切都完美,但当我编辑 xml 文件时,更改不会显示。我认为这可能是缓存的问题,因为文件已正确加载到服务器上。我该如何修复它?

-(IBAction)avviaParsing{


 NSString *urlstring=@"http://www.acicastelloonline.it/app_ios/show.xml";
    NSURL *xmlURL=[NSURL URLWithString:urlstring];  

    NSXMLParser *parser = [[ NSXMLParser alloc] initWithContentsOfURL:xmlURL];

    [parser setDelegate:self];

    [parser parse];

        [parser release];}

最佳答案

这里有三个选项,您应该在 XMLParsing 之前尝试此代码:

您仅选择三者之一。

清算

[[NSURLCache共享URLCache]removeAllCachedResponses];


禁用缓存

NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; 
[NSURLCache setSharedURLCache:cache]; 
[sharedCache release];

这是其他解决方案。

NSURL *xmlURL=[NSURL URLWithString:URL];
NSURLRequest *request = [NSURLRequest requestWithURL:xmlURL cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:0.0f];
NSXMLParser *xmlParser =[[NSXMLParser alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

关于ios - NSXML解析器缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11971966/

相关文章:

ios - 横向模式下的 TabBar 图像大小

iphone - Facebook iOS SDK : session invalid on iPhone after logging out of Facebook from a desktop

ios - Today ViewController 的主视图右移

ios - 如何在 Parse 中重置 iOS 推送通知角标(Badge)编号?

c# - 禁用输出缓存

ios - Realm iOS : Cannot Convert value of type 'Dogs.Type' to expected argument type 'T.Type'

c# - 使用 ImmutableSortedSet<T> 进行线程安全缓存

java - 存储经常使用的(不可更改的)List、Map 的最佳方式是什么?

Django 不反射(reflect)对应用程序所做的更改

caching - 直接映射缓存如何工作?