Created
July 22, 2013 16:07
-
-
Save kyktommy/6055086 to your computer and use it in GitHub Desktop.
IOS - File
write content to file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define directory and file path | |
NSString *documentDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; | |
NSString *filePath = [documentDir stringByAppendingPathComponent:@"file1.txt"]; | |
// Write NSArray to file | |
NSArray *numbers = @[@12, @124, @214214]; | |
[numbers writeToFile: filePath atomically:YES]; | |
NSError *error; | |
// List all Files in the directory | |
NSFileManager *fileManager = [NSFileManager defaultManager]; | |
NSArray *contents = [fileManager contentsOfDirectoryAtPath:documentDir error: &error]; | |
// Remove Item | |
[fileManager removeItemAtPath:filePath error: &error]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment