How to return the Temp application directory

I am trying to determine where to place the script file in the place where I can read / write while you are working in the sandbox. When reading the Apple documentation, I saw the following:

Some path search APIs (above the POSIX level) apply to specific applications outside the user's home directory. For example, in an isolated application, the NSTemporaryDirectory function provides a path to a directory that is outside the user's home directory but specific to your application and in your sandbox; you have unlimited read / write access for the current user. The behavior of these path finding APIs is appropriately configured for the Sandbox application and does not require code changes.

So basically I need to use the NSTemporaryDirectory function to return the application's Temp directory. But I can’t figure out how using the other documentation for NSTemporaryDirectory:

NSTemporaryDirectory Returns the path to the temporary directory for the current user.

NSString * NSTemporaryDirectory (void); Return Value A string containing the path to the temporary directory for the current user. If such a directory is not available, nil is returned.

Can someone please help me figure out where this temporary directory is or how to find it with some NSLog?

Please inform.

+4
source share
2 answers

How about just:

NSString *tempDir = NSTemporaryDirectory(); NSLog(@"tempDir='%@'", tempDir); 

EDIT . Updated response to save the value in a variable as requested by the OP.

+4
source

Use this file:

 #import <Foundation/Foundation.h> int main() { NSLog(@"Temporary directory is: %@", NSTemporaryDirectory()); return 0; } 

In general, however, NSTemporaryDirectory simply returns / tmp.

0
source

All Articles