2

I'm creating a Mac app that must run on Mac OS X Tiger. For some bizarre reason, it keeps crashing. The debugger returns the following error:

0x90a594d1 <+0033> mov (%edi,%edx,4),%eax

I've tried to Google the answer, but I found nothing. What am I doing wrong?

-(IBAction)loadPage:(id)sender{
    NSURL *URL = [NSURL URLWithString:@"http://www.google.com"];
    [NSURLConnection connectionWithRequest:[NSURLRequest requestWithURL:URL] delegate:self];
    NSLog(@"STARTED!");
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
    NSLog(@"STARTED!2");
    data = [[NSMutableData alloc]init];
}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)d{
    NSLog(@"STARTED!3");
    [data appendData:d];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{

    NSLog(@"STARTED!4");
    NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    NSLog(@"%@", str);

    [webView loadHTMLString:str baseURL:[NSURL URLWithString:[field stringValue]]];

    [str release];
    [data release];
}
Fernando Valente
  • 1,096
  • 1
  • 8
  • 30
  • How is "data" defined, and where does "field" come from? – Joachim Isaksson Feb 12 '12 at 07:31
  • On the header file. NSMutableData *data; IBOutlet NSTextField *field; – Fernando Valente Feb 12 '12 at 07:38
  • Can't really see anything obviously wrong that may cause the crash, sorry, think you'll have to try to track it down more using the debugger. You should really not allocate data in didReceiveResponse: though since it may be called multiple times. Do it in loadPage: instead, and just reset the length to 0 in didReceiveResponse. – Joachim Isaksson Feb 12 '12 at 08:04

1 Answers1

1

The solution was to retain the NSURLConnection

Fernando Valente
  • 1,096
  • 1
  • 8
  • 30