Question: how to read files of directory objective c
how to read files of directory in objective c?
[[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundleRoot error:nil]
To read the text file using objective c, you need to first get the path and load then load that content into the NSString as given below..
//loading the path NSString* path = [[NSBundle mainBundle] pathForResource:@"filename" ofType:@"txt"]; //Then loading the content into a NSString. NSString* content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];