开发者

how to say to Xcode that this file is stored on <myApp>/documents (iPhone)

开发者 https://www.devze.com 2023-01-09 07:57 出处:网络
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 pars

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"]

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号