【问题标题】:My iphone app crashes the first time i open the project我的 iphone 应用程序在我第一次打开项目时崩溃
【发布时间】:2011-04-03 13:46:24
【问题描述】:

它只崩溃一次,然后就可以正常工作了。

这里是项目: http://www.mediafire.com/?p0dy7g5ozkl69jt

【问题讨论】:

  • 能否发布崩溃报告?

标签: iphone crash


【解决方案1】:

您在尝试访问 GetXML 类中已发布的 NSURL 时遇到了内存问题... 那里:

- (void)main {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    >> NSData *xml = [NSData dataWithContentsOfURL:url];
...

要诊断这些,请使用 NSZombiesEnabled,explained there

要修复您的崩溃,请确保您在 GetXML 类中使用 retaincopy 网址:

- (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... ;)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-09
    • 1970-01-01
    • 2016-05-12
    • 1970-01-01
    相关资源
    最近更新 更多