Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
435 views
in Technique[技术] by (71.8m points)

ios - How to read pdf file from document directory with timestamp in iPhone?

i m having a problem i have too many pdf files so one by one i m downloading pdf files,

so i put timestamp with my document folder so mypath look like this:

/Users/zee/Library/Application Support/iPhone Simulator/6.0/Applications/10EF6B94-0ECD-484A-

AF5A-D300D8EF55DB/Documents/myPDF.pdf1382698338.78128

but i dont understand why its not opening in UIWebView with timestamp, my below code is

working when i dont put the timestamp.

so how can i open my pdf file that is attached with the timestamp below is my code please

help me out how to solve this problem

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,

 NSUserDomainMask, YES);

    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"myPDF.pdf"];

    NSURL *targetURL = [NSURL fileURLWithPath:filePath];

    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];

    [self.webView loadRequest:request];

my filepath is :

/Users/zee/Library/Application Support/iPhone Simulator/6.0/Applications/10EF6B94-0ECD-484A-

AF5A-D300D8EF55DB/Documents/myPDF.pdf1382698338.78128

Please tell me how can i open my pdf file

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

so i put timestamp with my document folder so mypath look like this:

              /Users/zee/Library/Application Support/iPhone Simulator/6.0/Applications/10EF6B94-0ECD-484A-AF5A-D300D8EF55DB/Documents/myPDF.pdf1382698338.78128

You should try using a different scheme for naming you files, so that the extension is kept unmodified, i.e.:

  ..../myPDF<TIMESTAMP>.pdf

e.g.

  ..../myPDF1382698338.78128.pdf

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...