1

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!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
P.Coder
  • 94
  • 9
  • 1
    if you want to save Video files permanently then you have to save it to DocumentDirectory . if you are saving those video's in Temporary directory then it may be deleted while facing memory pressure. – Saurabh Prajapati Jul 08 '16 at 06:43
  • Presumably these videos can be downloaded again if required, and there's no point in backing them up? – Wain Jul 08 '16 at 06:43

1 Answers1

0

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"

Community
  • 1
  • 1
Bhumit Mehta
  • 16,278
  • 11
  • 50
  • 64
  • I would like to keep videos for ever, but as far as I know, I have to exclude those files from iCloud backup process by setting false to NSURLIsExcludedFromBackupKey or apple will reject the app, is it true? – P.Coder Jul 08 '16 at 06:51
  • Yes you should mark those files as "Do not backup" as only those files which are user generated should be backed up to iCloud. I have update the answer with link to iOS Data Storage Guidelines – Bhumit Mehta Jul 08 '16 at 06:59