gpt4 book ai didi

ios - 文件路径为零

转载 作者:行者123 更新时间:2023-11-29 03:26:32 25 4
gpt4 key购买 nike

大家好,我是 ios 的新手

这是我的代码

       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];
}

最佳答案

而不是这个:

NSString  *filePath = [NSString stringWithFormat:@"%@/book_%@.pdf", documentsDirectory,comicbook_id];

使用

 NSString  *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString  stringWithFormat:@"book_%@.pdf",comicbook_id]];

关于ios - 文件路径为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20392236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com