它仅崩溃一次,然后正常工作。
这是项目:
http://www.mediafire.com/?p0dy7g5ozkl69jt
最佳答案
您在尝试访问NSURL
类中的已发布GetXML
时遇到内存问题。
那里:
- (void)main {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
>> NSData *xml = [NSData dataWithContentsOfURL:url];
...
要诊断这些,请使用NSZombiesEnabled,explained there。
要解决崩溃问题,请确保在GetXML类中使用
retain
或copy
url:- (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 ...;)
关于iphone - 我的iPhone应用程序在我第一次打开项目时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5529944/