【发布时间】:2015-01-08 21:51:06
【问题描述】:
我遇到了 NSXMLParser 的问题。我的源在 iOS7/XCode 5 中运行良好,但在 iOS8.1/XCode 6 中崩溃。崩溃错误是:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSXMLParser does not support reentrant parsing.'
我在this post 中尝试了其他解决方案,但仍然发生错误。任何人都可以帮助我更多?
我的来源是这样的
AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate, NSXMLParserDelegate>
{
NSXMLParser *xmlParser_;
...
}
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self parseData];
....
}
- (void)parseData
{
titleList_ = [[NSMutableArray alloc] init];
NSString *filePath = [[NSBundle mainBundle] pathForResource:fDetail ofType:fXML];
if (filePath)
{
NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
if (myText)
{
countPage_ = 2;
NSData *xmlData = [myText dataUsingEncoding:NSUTF16StringEncoding];//NSUTF8StringEncoding];
xmlParser_ = [[NSXMLParser alloc] initWithData:xmlData];
xmlParser_.delegate = self;
[xmlParser_ parse];
}
}
}
【问题讨论】:
标签: ios8 nsxmlparser