i'm new as an iphone developer, as a hobby i'm writting a small game (just for fun).
i would like to store the default configuration inside a xml file. I have the xml file, I know about how to parse the xml document, but.. what i do not know, and that's why i'm here is:
is there a way to say to Xcode: imagine this (xml) file is stored on /documents/ ? or the unique way is to copy&paste the (xml) file here: ~/Library/Application Support/iPhone Simulator/4.1/Applicat开发者_开发知识库ions//documents/
thanks!
fyi: the xml will always be together with the app.
just drag the xml into the file tree (solution explorer) in xcode
then to get the root directory path, just call
[[[NSBundle mainBundle] bundlePath] UTF8String]
that gets it as a char*, for c style string stuff. otherwise just leave out the UTF8String
[[NSBundle mainBundle] bundlePath] to get the NSString. just add your file name to the end
in my experience, it doesn't matter where you dump your xml in the 'solution explorer' it always ends up in the root directory.
better to use plist instead of xml . if u use plist then there is no need to parse it again.
end then use
NSString *theFolderPath = [NSHomeDirectory() stringByAppendingPathComponent:@"documents/YOUR FILE NAME"]
精彩评论