我正在创建一个必须在 Mac OS X Tiger 上运行的 Mac 应用程序。由于某种奇怪的原因,它不断崩溃。调试器返回以下错误:
0x90a594d1 <+0033> mov (%edi,%edx,4),%eax
我尝试用谷歌搜索答案,但一无所获。我做错了什么?
-(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/