iphone - How do I save an NSString as a .txt file on my apps local documents directory? -
How can I save an NSString as a .txt file on my apps Local Document Directory (UTF-8)?
NSArray * path = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString * document directory = [path item overindexx: 0]; // Get the directory of the document NSError * error; BOOL succeed = [myString writeToFile: [document directory stringbapping path comparison: @ "myfile.txt"] Atomically: Yes Encoding: NSUTF8 string encoding error: & amp; Error]; If (! Successful) {// handle error here}
Comments
Post a Comment