iPhone SDK Get tmp directory
Asked Answered
N

2

9

How do i get the tmp directory on the iPhone or iPad?

if i use NSTemporaryDirectory() to create a file it does not save to the simulator temp directory.

Nianiabi answered 6/6, 2010 at 4:40 Comment(2)
NSTemporaryDirectory() will do the right thing on a device.Landre
that works, fill it in as an answer and ill mark itNianiabi
N
21

As drawnonward said correctly in a comment

"NSTemporaryDirectory() will do the right thing on a device."

and thats true...

EDIT: Apparently there may be a problem with this approach on later Os's (>6.1.3), maybe try the NSCachesDirectory instead of the tmp directory.

Nianiabi answered 2/8, 2010 at 6:16 Comment(1)
Don't know. I have replaced it with NSCachesDirectoryNymphalid
R
1

As an alternative, from the documentation on NSFileManager URLForDirectory:inDomain:appropriateForURL:create:error:

You can also use this method to create a new temporary directory for storing things like autosave files; to do so, specify NSItemReplacementDirectory for the directory parameter, NSUserDomainMask for the domain parameter, and a valid parent directory for the url parameter. After locating (or creating) the desired directory, this method returns the URL for that directory. If more than one appropriate directory exists in the specified domain, this method returns only the first one it finds."

Rapping answered 25/7, 2012 at 4:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.