iPhone – Reading File in Resource Folder

Sometime you may need to bundle your files with the resource folder of the Xcode project such that u can manipulate those files on the fly.

If you have a resource file named as readme.txt, you can get the file path by

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"readme" ofType:@"txt"];  

 

If you have a resource file called myVoice.caf which is inside the folder named as Audio

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myVoice" ofType:@"caf" inDirectory:@"Audio"];  

After getting the filePath, you should be able to read the file.

Done =)

Reference:

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.