Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

alexandergre

macrumors member
Original poster
Jul 28, 2009
58
0
I found a tutorial on the net but cant figure it out.
In my view based application I have:

PDFViewController.h
Code:
@interface PDFViewController : UIViewController  {
	UIWebView	*webView;
	NSURL	*pdfUrl;
}

@property (nonatomic, retain) IBOutlet UIWebView	*webView;
@property (nonatomic, retain) NSURL			*pdfUrl;

@end


PDFViewController.m
Code:
#import "PDFViewController.h"

@implementation PDFViewController

@synthesize webView, pdfUrl;

#pragma mark -
#pragma mark UIViewController methods

- (void)viewDidLoad {
	[super viewDidLoad];
	[webView loadRequest:[NSURLRequest requestWithURL:pdfUrl]];
}


@end

where shall I have this code? in the app delegate?
:(
Code:
// Create an instance of PDFViewController
PDFViewController *controller = [[PDFViewController alloc] initWithNibName:@"PDFView" bundle:nil];
// Get the path to our documents directory
NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// This should be our documents directory
NSString *saveDirectory = [documentPath objectAtIndex:0];
// Our PDF is named 'Example.pdf'
NSString *saveFileName = @"Example.pdf";
// Create the full path using our saveDirectory and saveFileName
NSString *finalPath = [saveDirectory stringByAppendingPathComponent:saveFileName];
// Set the pdfUrl to our finalPath
controller.pdfUrl = [NSURL fileURLWithPath:finalPath];
// Push 'controller'
[self.navigationController pushViewController:controller animated:YES];
// Release 'controller'
[controller release];
 
EDIT: Problem REsolved. Apple documentation has some good stuff about PDF.
Thanx dejo.
 
So where does it actually go?

I've been working at this for hours now.

I tried to put it under applicationDidFinishLaunching: but I get one error for this next line.

[self.navigationController pushViewController:controller animated:YES];

The error says "Request for memeber 'navigationController' in something not a structure or union"

Please help.

Thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.