سؤال

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