Skip to content

Instantly share code, notes, and snippets.

@GenjiApp
Created January 29, 2012 03:06
Show Gist options
  • Save GenjiApp/1696941 to your computer and use it in GitHub Desktop.
Save GenjiApp/1696941 to your computer and use it in GitHub Desktop.
既存のものと同名のネームスペースを addNamespace すると、Snow Leopard 環境で Segmentation fault になる
#import <Cocoa/Cocoa.h>
int main(void)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSURL *fileURL = [NSURL fileURLWithPath:@"test.html"];
NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:fileURL
options:NSXMLDocumentTidyXML
error:nil];
NSXMLNode *namespaceNode = [NSXMLNode namespaceWithName:@"epub"
stringValue:@"http://www.idpf.org/2007/opf"];
NSXMLElement *rootElement = [xmlDoc rootElement];
/*
* In Lion, this statement is done normally.
* In Snow Leopard, "Segmentation fault" occurs.
*/
[rootElement addNamespace:namespaceNode];
NSLog(@"%@", rootElement);
[xmlDoc release];
[pool release];
return 0;
}
<!doctype html>
<html xmlns:epub="http://www.idpf.org/2007/opf" lang="ja">
<head>
<meta charset="utf-8" />
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment