开发者

My iphone app crashes the first time i open the project

开发者 https://www.devze.com 2023-02-22 05:44 出处:网络
It crashes only one time and then it works normally. Here开发者_运维问答 is the project: http://www.mediafire.com/?p0dy7g5ozkl69jtYou got a memory issue trying to access a released NSURL in your GetX

It crashes only one time and then it works normally.

Here开发者_运维问答 is the project: http://www.mediafire.com/?p0dy7g5ozkl69jt


You got a memory issue trying to access a released NSURL in your GetXML class... There:

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

To diagnose these, make use of NSZombiesEnabled, explained there.

To fix your crash, make sure you retain or copy your url in your GetXML class :

- (id)initWithURL:(NSURL*)newURL delegate:(id <GetXMLDelegate>)newDelegate
{
    self = [super init];
    url = [newURL copy]; // there
    delegate = newDelegate;

    return self;
}

and to avoid a memory leak, make sure your release that URL

- (void)dealloc {
  [url release];
  [super dealloc];
}

Untested code, but should work... You should re-read Apple documentation about memory management... ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消