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?
 

lawicko

macrumors member
Jul 17, 2008
44
0
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.
 

detz

macrumors 65816
Original poster
Jun 29, 2007
1,051
0
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.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
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.