Posted By

BenClayton on 03/31/10


Tagged


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

umang_nine
avanadra
sb
cnathan


Write string to file in documents folder


 / Published in: Objective C
 

  1. NSString *myString; //Assuume the string you want to write is this
  2. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  3. NSString *documentsDirectory = [paths objectAtIndex:0];
  4. NSString *path = [documentsDirectory stringByAppendingPathComponent:@"myfile.txt"];
  5. [myString writeToFile:path atomically:YES];

Report this snippet  

You need to login to post a comment.