gpt4 book ai didi

iPhone 应用程序在解析 XML 时卡住

转载 作者:行者123 更新时间:2023-12-03 20:02:01 25 4
gpt4 key购买 nike

每当我解析 XML feed 时,我的应用程序就会卡住。

我尝试过这样调用:

[NSThread detachNewThreadSelector:@selector(parseXML) toTarget:self withObject:nil];

调用:

-(void) parseXML {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self parseXMLFileAtURL:path];
[pool drain];
}

但我的应用程序因此变得相当不稳定...iPhone 模拟器刚刚崩溃,没有错误警告。

最佳答案

而不是调用:

[NSThread detachNewThreadSelector:@selector(parseXML) toTarget:self withObject:nil];

你应该打电话:

[self performSelectorInBackground:@selector(parseXML) withObject:nil]

您的 UI 卡住是因为您在 UI 线程中执行冗长的操作。

关于iPhone 应用程序在解析 XML 时卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2136056/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com