3
NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"sampleLayout.pdf" withExtension:nil];

This above line warns NSBundle may not respond to -URLForResource:withExtension: and the app crashes while loading the PDF file from this URL path.

James M
  • 18,506
  • 3
  • 48
  • 56
The Debugger
  • 330
  • 8
  • 19
  • If you're getting a warning and a crash, than this method doesn't exist. Are you using an earlier SDK? This method was added to iOS with 4.0 and won't exist prior to that (so if you are building for 3.2 or 3.1 or something...) – Jason Coco Oct 25 '10 at 04:39
  • yes, Jason i'm doing this for iPad and so it runs on 3.2, sorry i was not mentioned earlier – The Debugger Oct 25 '10 at 07:30

2 Answers2

12

Why dont you try like this..?

NSString *urlPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:urlPath];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[webViewOutlet loadRequest:urlRequest];
Ajith
  • 1,457
  • 3
  • 16
  • 29
  • 1
    Thanks Aji i tried this before, it also crashed without any warning. Anyway it will be useful for my web service request,.. now i'm drawing this pdf file in drawing context – The Debugger Oct 25 '10 at 07:41
0

NSURL *pdfPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"]];

i got working from this above line, i think this is alternative for ipad 3.2 from iphone 4.0 os

The Debugger
  • 330
  • 8
  • 19