Reading text file with NSString:stringWithContentsOfFile?
NSString *txtFilePath = [[NSBundle mainBundle] pathForResource:@"help" ofType:@"txt"];
NSString *txtFileContents = [NSString stringWithContentsOfFile:txtFilePath encoding:NSUTF8StringEncoding error:NULL];
NSLog(@"File: %@",txtFileContents);
I get "null" as the result. How do I know what path to specify?
thanks
(I placed the file just under "Groups and Files" ... so not sure if I need to specify a path or just the file name. Maybe there is something else wrong ???
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…