Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 views
in Technique[技术] by (71.8m points)

objective c - iOS temporary folder location

My app has just been rejected by Apple because it was storing temporary or cache files in the documents directory. Right. Their rejection message states:

Temporary files used by your app should only be stored in the /tmp directory

I suppose it is that besides the Documents and Library in the Application's folder.

I am now trying to debug this issue in the iPhone Simulator, and when I use NSTemporaryDirectory(), the value I get in the Xcode debugger is /var/folders/yj/gnz1c7156c7d6d4fj429yms40000gn/T/tempzip.zip, and not /Users/me/Library/Application Support/iPhone Simulator/5.1/Applications/8F71AB72-598C-427A-A116-36833D3209F7/tmp/tempzip.zip.

So: is NSTemporaryDirectory() having a different behaviour using the iPhone Simulator, and, is it possible to track the application's temporary directory at debug time ?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

iOS 9 or later ? Swift 3 or later

let tmpDirURL = URL(fileURLWithPath: NSTemporaryDirectory())

iOS 10.0+Beta, macOS 10.12+, tvOS 10.0+Beta & watchOS 3.0+ ? Xcode 8 ? Swift 3 or later

let tmpDirURL = FileManager.default.temporaryDirectory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...