【发布时间】:2014-03-27 00:33:52
【问题描述】:
我以前做过很多次,但现在失败了。 我想访问我的应用程序中附带的文件。
NSString* path = [[NSBundle mainBundle] pathForResource:@"information" ofType:@"xml"];
返回
/Users/eldude/Library/Application Support/iPhone Simulator/7.0.3/Applications/5969FF96-7023-4859-90C0-D4D03D25998D/App.app/information.xml
这是正确的 - 在终端中检查等等。但是,尝试解析路径失败
NSURL* fileURL = [NSURL URLWithString:path];
NSXMLParser *nsXmlParser = [[NSXMLParser alloc] initWithContentsOfURL:fileURL];
[nsXmlParser setDelegate:self];
if(![nsXmlParser parse]){
NSError* e = nsXmlParser.parserError;
NSLog(@"ERROR parsing XML file: \n %@",e);
self = NULL;
}
与
Error Domain=NSCocoaErrorDomain Code=-1 "The operation couldn’t be completed. (Cocoa error -1.)" UserInfo=0xb9256f0 {NSXMLParserErrorMessage=Could not open data stream}
有什么想法吗?
【问题讨论】:
-
néelam 的回答:stackoverflow.com/questions/6263289/…
标签: ios ios7 swift nsxmlparser