【发布时间】:2012-09-12 17:10:35
【问题描述】:
我使用 TBXML 从网上下载一个 .xml 文件。我正确解析了文件,我得到了我想要的所有数据。
我的问题是我更新了服务器上的文件,但它没有在应用程序中更新。它只在我删除并重新安装应用程序时更新文件。
有什么缓存之类的吗?
这就是我订购 fetch 的方式:
-(void)getXML {
NSLog(@"Updating ATC data !");
// Create a success block to be called when the async request completes
TBXMLSuccessBlock successBlock = ^(TBXML *tbxmlDocument) {
// If TBXML found a root node, process element and iterate all children
if (tbxmlDocument.rootXMLElement)
[self traverseElement:tbxmlDocument.rootXMLElement];
};
// Create a failure block that gets called if something goes wrong
TBXMLFailureBlock failureBlock = ^(TBXML *tbxmlDocument, NSError * error) {
NSLog(@"Error! %@ %@", [error localizedDescription], [error userInfo]);
};
// Initialize TBXML with the URL of an XML doc. TBXML asynchronously loads and parses the file.
TBXML *tbxml = [[TBXML alloc] initWithURL: [NSURL URLWithString:@"http://www.mysite.com/myFile.xml"]
success: successBlock
failure: failureBlock];
}
这就是我在后台调用它的方式:
[self performSelectorInBackground:@selector(getXML) withObject:Nil];
在后台调用它可能没用,因为 TBXML 是异步工作的,如果有人能确认我会把它拿走的话。另外,我不认为我的traverseElement: 方法的代码在这里有用,因为文件被正确解析。
感谢您的帮助!
【问题讨论】:
-
嗨,请告诉我你是如何解决这个问题的,因为我也遇到了同样的问题!它一直在加载旧的缓存 xml 文件,并且从不查看来自服务器的新文件!我必须删除该应用程序才能获得新的应用程序。 :(
-
对不起,但正如我的回答所说,我不知道是什么解决了这个问题..
-
OK 酷,有没有其他人知道什么会导致这种情况发生?