i want to write a string in a file "file.txt": this file in my project (for Iphone) is inside Resources; I try to write a string in this file but it don't work, I show my code.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"file.txt"];
NSError *error;
[outputString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error];
I want write in this file with simulator xcode, not with device
I'm not sure if you are able to write in your bundle, but you can in your Documents directory instead as your code does. Why don't you try this?
Use the same code and you will find your file in:
/Users/YOURUSER/Library/Application Support/iPhone Simulator/IOSVERSION/Applications/APPID/Documents/file.txt