D detz macrumors 65816 Original poster Oct 14, 2008 #1 NSString *resource = [[NSBundle mainBundle] pathForResource😡"test" ofType😡"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?
NSString *resource = [[NSBundle mainBundle] pathForResource😡"test" ofType😡"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?
robbieduncan Moderator emeritus Oct 14, 2008 #2 Are you 100% sure it's called "test.txt" not "Test.txt" or "test.TXT" for example?
L lawicko macrumors member Oct 14, 2008 #3 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.
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.
D detz macrumors 65816 Original poster Oct 14, 2008 #4 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.
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 Oct 14, 2008 #5 NSString stringWithContentsOfFile: is deprecated and there's no reason that you should use it. Use stringWithContentsOfFile:encoding:error:
NSString stringWithContentsOfFile: is deprecated and there's no reason that you should use it. Use stringWithContentsOfFile:encoding:error: