Int retVal = UIApplicationMain (argc, argv, nil, nil); EXC_BAD_ACCESS when trying to load pdf into webView

Hi guys, you are my last chance to find this mistake. I searched all day and could not find anything.

What I am doing is saving the PDF file from the network locally and then uploading it to webView . On iOS 4.0 and 4.1, it gives me a BAD_ACCESS error, while on iOS 4.2 and 4.3 it works fine.

This is the code I'm using:

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"press.pdf"]; filePath = [[NSURL fileURLWithPath:path]retain]; NSError *err =nil; if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { //if file already exists delete it NSLog(@"file is already there !"); [[NSFileManager defaultManager] removeItemAtPath:path error:&err]; NSLog(@"error: %@",err); } [responseData writeToURL:filePath atomically:YES]; [responseData release]; if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { NSLog(@"file is there"); NSData *pdfFile = [[NSData alloc]initWithContentsOfFile:path ]; [webView loadData:pdfFile MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil]; [pdfFile release]; } else{ NSLog(@"file not there"); } 

I tried to enable NSAutoreleaseFreedObjectCheckEnabled , NSZombieEnabled and NSDebugEnabled , but I get nothing in the console. Xcode just stops at this line:

 int retVal = UIApplicationMain(argc, argv, nil, nil); 

and EXC_BAD_ACCESS states

I do not know what it can be and where to look further. Please, help

EDIT: I forgot to mention that if I comment on the next line, this is obviously not a failure because nothing is loaded in the webView.

 [webView loadData:pdfFile MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil]; 
+4
source share
2 answers

Try commenting out all release statements as a start ... if the failure goes away, start narrowing down, which causes the problem. Also: you should really study auto-advertising because in many cases you save unnecessarily in the code above.

If that doesn't work, try commenting out fragments of your code in half to find out where it really explodes (obviously NOT where Xcode shows).

+1
source

I had the same problem, and it has something to do with auto-correction in the simulator.

Simulator> Settings> General> Keyboard> AutoCorrect = Off

0
source

All Articles