the physical path for my files inside the Resources folder of XCode (for IOS)

南楼画角 提交于 2020-01-14 14:54:12

问题


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?



来源:https://stackoverflow.com/questions/6172165/the-physical-path-for-my-files-inside-the-resources-folder-of-xcode-for-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!