When writing a Cocoa app with PyObjC it can be easy to fall into the bad habit of storing the wrong kind of data inside the
.appfolder. For example, in an application I am writing I use an SQLite database which I access from inside the
.appfolder like this:
Because that database contains immutable data, storing it inside the
.appfolder is an appropriate place for it to exist. However, in that same app I also need to store some user specific data. Unlike the immutable database, the correct place to store user specific data is in a subfolder of
The function to calculate that folder can be implemented like this:
That will allow us to find the support folder for any application (as long as we know its name), but we can make it even more useful by building a second function on top which builds the complete path for a given filename.
pathForFilenamelooks like this:
Let me know if there are any questions or comments.