I'm using NSFileManager to create a file at a specified path with text view contents. I'm using following code
[[NSFileManager defaultManager] createFileAtPath:saveFileName contents:[[tView text] dataUsingEncoding:NSASCIIStringEncoding] attributes:nil];
But the problem is that, its creating file with no contents. I'm sure that text contents are not nil. How can I check and confirm that data is written into file.
Some suggestions:
[tView text]
to make sure it is not empty. NSUTF8StringEncoding
or NSUTF16StringEncoding
. Localization may be a problem with plain ASCII encoding because ASCII does not handle multibyte character encodings.
Well, I know it's few months late, but you're sending NSString instead of NSData to the contents:
parameter.
Try:
[[tView text] dataUsingEncoding:NSUTF8StringEncoding]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.