【发布时间】:2011-04-03 13:46:24
【问题描述】:
它只崩溃一次,然后就可以正常工作了。
【问题讨论】:
-
能否发布崩溃报告?
它只崩溃一次,然后就可以正常工作了。
【问题讨论】:
您在尝试访问 GetXML 类中已发布的 NSURL 时遇到了内存问题...
那里:
- (void)main {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
>> NSData *xml = [NSData dataWithContentsOfURL:url];
...
要诊断这些,请使用 NSZombiesEnabled,explained there。
要修复您的崩溃,请确保您在 GetXML 类中使用 retain 或 copy 网址:
- (id)initWithURL:(NSURL*)newURL delegate:(id <GetXMLDelegate>)newDelegate
{
self = [super init];
url = [newURL copy]; // there
delegate = newDelegate;
return self;
}
为避免内存泄漏,请确保您发布该 URL
- (void)dealloc {
[url release];
[super dealloc];
}
未经测试的代码,但应该可以工作...您应该重新阅读Apple documentation about memory management... ;)
【讨论】: