Search code examples
objective-ciosxcodefilepathnsbundle

accessing a file using [NSBundle mainBundle] pathForResource: ofType:inDirectory:


I have a file paylines.txt added inside the folder named TextFiles which resides inside the Resources folder of my iOS project in Xcode.

This is the code I use to access the file:

NSString* filePath = [[NSBundle mainBundle] pathForResource:@"paylines" ofType:@"txt" inDirectory:@"TextFiles"];
NSLog(@"\n\nthe string %@",filePath);

The code prints:

2011-06-07 14:47:16.251 slots2[708:207] 

the string  (null)

Solution

  • well i found out the mistake i was committing i was adding a group to the project instead of adding real directory for more instructions