简体   繁体   中英

ios: Where should I keep application data files, Temp or Document folder?

I'm building a video library application using Swift, I am wondering where to keep downloaded video files, is it better to use Document folder or just using the temp folder.

let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0]
// OR
let documentsPath = NSTemporaryDirectory()

Thanks!

If want user to be able to access the videos from iTunes ( See here on how to do it ) than you should save videos in DocumentDirectory and if those videos are not that usefull and should be deleted than you can save them in NSTemporaryDirectory . It depends on how important are those videos in your app.

Videos in DocumentDirectory will be saved permanently while NSTemporaryDirectory can be cleared by OS when device is running short of memory as it is assumed that content in NSTemporaryDirectory is not that critical and should be redownloaded by app if needed

Also follow remember to follow this iOS Data Storage Guidelines guidelines and mark your files as "Do not backup"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM