I'm working with an SSH library and I have a part in my application where you can create an HTML document by writing it in UITextView, then I want to be able to upload it to the server. I'm stuck on the part where I have to save the text file in a ".html" format temporarily, before uploading to a server. I know I can get all the text from the text view, but how do I give it a filename extension? Thanks!
I referred to this SO thread to learn about saving it to file, but how do I access the file once it's saved?
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
NSString *documentTXTPath = [documentsDirectory stringByAppendingPathComponent:@"test.html"];
htmlCode = self.htmlText.text;
NSError* error = nil;
[htmlCode writeToFile:documentHTMLPath atomically:YES encoding:NSASCIIStringEncoding error:&error];
NSStringEncoding encoding;
NSString* fileToUpload = [NSString stringWithContentsOfFile:documentHTMLPath usedEncoding:&encoding error:&error];