开发者

iPhone SDK Get tmp directory

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 si开发者_开发百科mulator 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."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜