문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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."

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top