Temporary Directory (NSTemporaryDirectory)

Discussion in 'Mac Programming' started by mdeh, Feb 10, 2009.

  1. mdeh macrumors 6502

    Jan 3, 2009
    A rather dumb but hopefully easy question.

    Does the OS keep a TemporaryDirectory at all times.

    So the call;

    tempDir = NSTemporaryDirecory;

    simply returns an existing Directory?

    Once the programmer is done with this, does it have to be deleted?

  2. larkost macrumors 6502a

    Oct 13, 2007
    A quick look at the documentation indicates that this returns the user temporary items folder in /private/var/tmp/folders. This does not get erased on reboot, and is available to all processes running as that user. So you should create a directory inside that (or in /tmp if you want it to go away even if you crash) and then remove it at the end of your run.
  3. mdeh thread starter macrumors 6502

    Jan 3, 2009

    Thanks larkost.

    When you say "a quick look at the documentation", where exactly did you look. The documentation to a newbie can be pretty daunting.

Share This Page