Here we are sharing how to Create a file and write in it.
Just copy and paste into .m file in your project
//This is our Writing part:
NSArray *filepath =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsdirectory=[filepath objectAtIndex:0];
NSLog(@"Document directory>>>%@",documentsdirectory);
NSString *filename=[NSString stringWithFormat:@"%@/myfile.txt",documentsdirectory];
NSString *content=@"One\nTwo\nThree\nFour\nFive";
[content writeToFile:filename atomically:YES encoding:NSStringEncodingConversionAllowLossy error:nil];
//Writting part end.
//This our Reading part
NSArray *path= NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentdir=[path objectAtIndex:0];
NSString *filename=[NSString stringWithFormat:@"%@/myfile.txt",documentdir];
NSString *cont=[[NSString alloc]initWithContentsOfFile:filename usedEncoding:nil error:nil];
NSLog(@"content>>%@",cont);
Reading part end.
Iphone application development to extend the memory configuration for storing files in it.
ReplyDeleteiphone app
Appreciated..!! Thank you for this code.
ReplyDeleteiPhone App Developers
Cheers
I have read this blog that provide good information regarding how to Read/Write text to File in iPhone or iPad app with the help of code and which is useful for me or other people.Thanks. .
ReplyDeleteIndeed! This method is really simple and it will be good for those who are new to iPhone App Development like me.Thanks
ReplyDeleteThanks for complements all of you, if you need more so you can suggest me whatever i can share with you it will be my pleasure.
ReplyDeleteWe decided to help you out with design portfolio templates, Ideas, and Inspiration for your portfolio. Some of the portfolio designs can also be downloaded as templates which means you can use the design and layout to create your own portfolio from the file.
ReplyDelete