the physical path for my files inside the Resource

2019-07-04 22:06发布

问题:

I'm developing an application for iPad. I want to access a text file inside the Resources folder! I'm doing that in following way:

 NSString* filePath = @"/Users/net4uonline/Desktop/slots2/paylines.txt";

Now, if I move my whole project from Desktop to somewhere else I know this won't work. So, is there any way to give a relative path for this file instead of the current path. Maybe like the following?

NSString* filePath = @"Resources/paylines.txt";

I know this won't work but as my file is always going to reside inside the Resources folder, so I thought this might work!

回答1:

I guess you are looking for NSBundle and pathForResource:ofType: method, aren't you?