I do not know how this problem is generally called and plus I'm pretty new with XCode programming. (So this may be a duplicate question)
My OS X application uses some files and .db files which path differs in any computer the project is moved obviously.
For example:
/Users/**MYnamehere**/XCode/**projectnamehere**/file.txt
the path of this file contains my username, so when I use it in my code it works fine, but as soon as I move the project to my second computer, the compiler for sure doesn't know the path because the path is specific to my first computer.
Is there anything to do to bond the path to the project? So that when I move the project to other computer or I just export the application to be shared, nobody will have problems?
This is kind of easy to solve I think but I don't know how and where to look for an answer. So I tried to ask to you. Thank you.
If you need to know the path to the users home dir you can use the
NSHomeDir()
method as described hereIf you need access to other directories - or just need to do some file related work in general - you can use the NSFileManager.
For instance, if you need to find the location of the users Documents dir you could use the NSFileManager like so:
Which rewards me with this
URL: file:///Users/peter/Documents/
In the above case you could probably just use
NSUserDomainMask
as the domain parameter but you get the idea :-)