我使用TBXML从web上下载了一个.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:方法的代码在这里有用,因为文件被正确地解析了。
感谢你在这里的帮助!
发布于 2012-11-20 23:38:21
这个问题似乎消失了..它工作得很好,但我不知道为什么它一开始就不能工作。
https://stackoverflow.com/questions/12510868
复制相似问题