Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

detz

macrumors 65816
Original poster
Jun 29, 2007
1,051
0
NSString *resource = [[NSBundle mainBundle] pathForResource:mad:"test" ofType:mad:"txt"];
NSString *content = [NSString stringWithContentsOfFile:resource];

there is a test.txt file in my Resource directory but both of these values are nil. Any ideas?
 
I notice that sometimes there is a problem if you release the path to the resource to early, so try not to release resource string before you actually use content object.
 
Weird, I tried everything and the only thing that worked was deleting the txt file and re-creating it. Maybe there was an encoding issue or something.
 
NSString stringWithContentsOfFile: is deprecated and there's no reason that you should use it. Use stringWithContentsOfFile:encoding:error:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.