Write string to file in documents folder


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.