Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mikezang

macrumors 6502a
Original poster
May 22, 2010
854
7
Tokyo, Japan
I use code as below to get path of tmp and documents, but they are in different location, I knew that documents folder is right, I want to know if this tmp folder is correct?
Code:
[NSTemporaryDirectory() stringByAppendingPathComponent:fullFileName]

Documents Folder:/Users/mikezang/Library/Application Support/iPhone Simulator/3.2/Applications/E7A7C5DF-1095-40CC-89DB-7AE036FE5468/Documents/database.sqlite3

Tmp Folder:/var/folders/+D/+DggSL7nF8OME3lFbWxEDk+++TI/-Tmp-/
 

ianray

macrumors 6502
Jun 22, 2010
452
0
@
The whole point of the NSTemporaryDirectory() API is that you do not have to care where the temporary directory is located! Why do you need to know this implementation detail?
 

mikezang

macrumors 6502a
Original poster
May 22, 2010
854
7
Tokyo, Japan
I thought it should be in the same folder as Documents
/Users/mikezang/Library/Application Support/iPhone Simulator/3.2/Applications/E7A7C5DF-1095-40CC-89DB-7AE036FE5468/tmp
 

bindle

macrumors regular
Aug 29, 2008
150
110
Yeah as long as you're accessing it the right way, you don't need to worry about where it is.
But to answer, the Simulator will use that /var/folders directory for tmp. Run on the device, the tmp directory will be located in the sandbox directory structure you expect.
 

taberrr

macrumors regular
Jun 19, 2007
106
1
NY
It matters if you want to quickly be sure to tell that files you are writing are showing up, and to keep track of how many you've outputted if you're testing batch file operations etc.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
NSTemporaryDirectory() is the correct way to access the /tmp folder. It is located in different places on the Sim and device. On the device it is inside your app sandbox. On the Sim it is the system tmp folder.

You might need to treat them differently between Sim and device. On the Sim the temp folder is shared with other apps but not on the device. On the Sim you need to be careful to only delete files/folders that your app has created and there's a small chance of name conflicts.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.