开发者

How to save filename with space on Iphone

I am trying to save file in document directory using

NSString *documentDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES) lastObject];
NSString *filename=[NSString stringWithFo开发者_高级运维rmat:@"abc 1.pdf",];
NSString *pdfLocation = [documentDirectory stringByAppendingPathComponent:filename];

I am opening this file using a web view

NSURL *url = [NSURL URLWithString:pdfLocation];
NSURLRequest *urlRequest = [[NSURLRequest alloc] initWithURL:url];
[self.webView loadRequest:urlRequest];
[urlRequest release];

This fails if the the file name has a space.How should I save file so that space in the filename is maintained.


UIWebView expects a file URL in this case. Change the line to:

NSURL *url = [NSURL fileURLWithPath:pdfLocation];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜