Reputation: 51
hi to every one i am new to ios
here is my code
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *comicbook_id = [[NSUserDefaults standardUserDefaults]stringForKey:@"comicbook_id"];
NSString *filePath = [NSString stringWithFormat:@"%@/book_%@.pdf", documentsDirectory,comicbook_id];
documentsDirectory = [documentsDirectory stringByAppendingPathComponent:filePath];
NSLog(@"date==>%@",documentsDirectory);
***here i am getting path***
ReaderDocument *document = [ReaderDocument withDocumentFilePath:documentsDirectory password:nil];
NSLog(@"date==>%@",document);
*****here i am getting <nil>*****
if (document != nil) {
ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
readerViewController.delegate = self;
readerViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
readerViewController.navigationController.navigationBar.tintColor = [UIColor blackColor];
readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:readerViewController animated:YES completion:nil];
}
Upvotes: 0
Views: 291
Reputation: 51
those who are not using ARC and need Reader view controller.please go to the builphases in ur project--->complie sources-->it will list the .m file list please click on which .m which reader have open project, have .m file and double click those one's and write "-fobjc-arc"
automatically reader read's those thanks ya...
Upvotes: 0
Reputation: 4671
Instead of this :
NSString *filePath = [NSString stringWithFormat:@"%@/book_%@.pdf", documentsDirectory,comicbook_id];
use
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"book_%@.pdf",comicbook_id]];
Upvotes: 1