views:

24

answers:

1

How do I retrieve the project directory of an xcode project targeted for the ipad? Or if it isn't possible, then how do it retrieve the home directory of the user?

something like:

NSString *path = [NSProject getPath];//could be absolute or relative

or

NSString *homeDir = [NSURL getUserDirectory];
A: 

The user directory is not publicly writable in iOS. Where to store files depends on your goal, but it will always be within your app sandbox. Apple sets out guidelines in their iOS Application Programming Guide:

<Application_Home>/AppName.app
<Application_Home>/Documents/
<Application_Home>/Library/Preferences    
<Application_Home>/Library/Caches
<Application_Home>/tmp/

If you would like to expose files in /Documents to other applications, including iTunes on the desktop, then enable file sharing.

Justin
hi, thanks for your response. I don't intend to write on the directory, I just want to read the path of the project directory of the user developer's home path, so I could use that information to preprocess something before the project gets compiled
ivanceras
I'm sorry, I misunderstood your question. Perhaps what you're looking for is information on the directory variables accessible from the Run Script build phase? See here: http://developer.apple.com/iphone/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/200-Build_Phases/bs_build_phases.html#//apple_ref/doc/uid/TP40002690-CJABHEIB
Justin