Search code examples
objective-ccocoaapp-storesandboxtemporary-files

Create temp file for a sandboxed Cocoa application


My app is sandboxed (as per the latest App Store guidelines), and I want to create some temporary files.

Am I allowed to do so? If "yes", WHERE am I allowed to do it? Is there any prespecified path? (And a command to access that path?)


Solution

  • You should use the NSTemporaryDirectory() function, which will find and return the appropriate temporary folder for your application (regardless of sandbox status, OS version, and a host of other things). Take a look at this Cocoa With Love post for much more detail about NSTemporaryDirectory() and other temporary directory-related details.