0

我正在开发一个使用 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];}
4

1 回答 1

1

here is three option, you should try this code before XMLParsing:

you select only one of the three.

clearing

[[NSURLCache sharedURLCache] removeAllCachedResponses];


disable cache

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

this is other solution.

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];
于 2012-08-15T15:14:17.500 回答