我正在创建必须在Mac OS X Tiger上运行的Mac应用程序。由于某些奇怪的原因,它一直崩溃。调试器返回以下错误:



我尝试用Google回答,但什么也没找到。我究竟做错了什么?

-(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];
}

最佳答案

解决方案是保留NSURLConnection

关于objective-c - NSURLConnection异常崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9247178/

10-14 20:01