Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6081551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:11:19+00:00 2026-05-23T11:11:19+00:00

I a, saving a pdf file from the web locally and then loading it

  • 0

I a, saving a pdf file from the web locally and then loading it in a webView. In iOS 4.0 and 4.1, it gives me BAD_ACCESS error while in iOS 4.2 and 4.3 it works fine.

This is the code I am 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 in the console I get nothing.
Xcode just stops at that line:

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

and states EXC_BAD_ACCESS

I do not have any idea what it could be and where to look next.

EDIT: I forgot to mention that if I comment the following line out it obviously doesn’t crash because nothing is loaded into the webView.

[webView loadData:pdfFile MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:11:20+00:00Added an answer on May 23, 2026 at 11:11 am

    Try commenting out all the release statements as a start… if the crash goes away, start narrowing down which one is causing the problem. Also: you should really study autorelease, because in a lot of cases you are retaining unnecessarily in the code above.

    If that doesn’t work, try commenting out pieces of your code bit by bit to figure out where it is really blowing up (obviously NOT where XCode shows).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam trying to saving an UIImage in PDF file. How can i do this?
I have code (in a .ashx-file) that generates a PDF file from a PDF
I'm trying to save a file (pdf or image) uploaded from a form into
i am using prawn gem to generate pdf file, pdf.render_file('csv.pdf') is saving the file
I'm saving out a .csv file from Excel and importing it to a MySQL
I have a requirement to download a PDF file and saving it on clicking
How to use TCPDF to output pdf file in browser without saving like in
I am doing conversion from XHTML to PDF using flying saucer, it works perfectly
Currently we are saving files (PDF, DOC) into the database as BLOB fields. I
Saving data to Postscript in my app results in a Postscript file which I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.