当我释放一个CXMLDocument时,我得到了一个EXEC_BAD_ACCESS错误。
下面是我的非常简单的代码,它没有依赖项:
@implementation TestViewController
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSError *xmlError = nil;
CXMLDocument *xmlDoc = [[CXMLDocument alloc] initWithXMLString:@"<test></test>" options:0 error:&xmlError];
CXMLElement *rootElement = [xmlDoc rootElement]; // Unused local variable
[xmlDoc release];
}如果我注释掉CXMLElement *rootElement = [xmlDoc rootElement];或者保留它,就不会出现错误。
调用[xmlDoc rootElement]如何导致xmlDoc释放过多?这是一个TouchXML错误,还是我遗漏了一些非常基本的东西?
这里有类似的问题,但没有有效的答案:Weird crash if I try to release CXMLDocument
发布于 2011-08-23 21:31:43
当我关闭Guard Malloc的时候,崩溃就消失了。假设Guard Malloc是可靠的,这看起来像是一个Touch XML bug。
发布于 2011-07-30 06:11:55
这是获取rootElement的正确方式吗?我从未使用过TouchXML,但从我所能找到的信息来看,获取rootElement似乎是相应的
NSArray *foundRoots = [theXMLDocument nodesForXPath:@"//Root" error:&xmlError];
CXMLElement Root = [foundRoots objectAtIndex:0];发布于 2013-09-24 16:08:50
我经常使用TouchXML,而且(幸运的是?)到目前为止我还没有遇到这个问题,但是它就这样发生了…
我在这里发布了一个解决方案:Memory crash using [CXMLNode nodesForXPath] with namespace mappings
https://stackoverflow.com/questions/6879322
复制相似问题