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];
精彩评论