Say for example In Xcode I make 3 folders in my supporting files older named “a” “b” and “c”.
In each of these folders I have an xml file name “file.xml”.
How can I use NSMainBundle to get paths to these 3 different xml files?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To get these files at runtime Xcode will copy them in the Copy Bundle Resource phase. This normally copies into the root of the bundle. To deal with directories see @CocoaFu’s answer to this SO question.
Then in the code
NSBundle* bundle = [NSBundle mainBundle]will give you the main bundleFrom this you look in directories using pathForResource:ofType:inDirectory: e.g.
The methods are given in NSBundle class reference also see the Bundle Programming guide