Is this tmp folder correct?

Discussion in 'iOS Programming' started by mikezang, Aug 28, 2010.

  1. mikezang macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #1
    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-/
     
  2. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #2
    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?
     
  3. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #3
    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
     
  4. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
  5. bindle macrumors regular

    Joined:
    Aug 29, 2008
    #5
    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.
     
  6. taberrr macrumors regular

    Joined:
    Jun 19, 2007
    Location:
    NY
    #6
    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.
     
  7. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #7
    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.
     

Share This Page