Take the 2-minute tour ×

How can I create a directory inside NSTemporaryDirectory? I tried something like:

[NSTemporaryDirectory() stringByAppendingPathComponent:@"/myTmp/"];

followed by the file name, but it didn't work.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Use NSFileManager to create the directory for you:

[[NSFileManager defaultManager] createDirectoryAtPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"/myTmp/"] 
    withIntermediateDirectories:YES attributes:nil error:nil];
share|improve this answer
Thanks :-) Just a small comment: this method has to be used with an instance of NSFileManager. –  Adriana Jul 27 '11 at 16:48
@Adriana You are correct. I updated my answer. –  highlycaffeinated Jul 27 '11 at 18:00
Do you know how could I create the directory with the permissions drwx------? I've been trying, but I always get a different permission. –  Adriana Jul 28 '11 at 10:51

Your Answer


