The createFileAtPath:contents:attributes for Objective-C: contents requires an NSData type, but I want to create a file with a NSString content. How do I do this?
I know it’s probably a really basic answer, but I’m just starting to learn how to use Objective-C, and it has so many different data types and objects compared to other languages I’ve used.
Thanks!
You can try creating
NSDatawith the content of the string, like this:You can also store an
NSStrngto a file directly:NOTE This answer is edited after Ken Thomases’s note.