Can I save the downloaded files to NSCacheDictionary in iphone?

大兔子大兔子 提交于 2019-12-11 18:44:00

问题


I am downloading some mp3 files through my application using NSURLConnection. Actually where can I save the downloaded file. Someone says that saving in to NSDocumentDirectory will lead to app rejection.

Can I save the file to NSCacheDictionary and retrieve this from itunes?

I used this bit of code to save files to NSCacheDictionary

   NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(
                                                            NSCachesDirectory, NSUserDomainMask, YES)
                        objectAtIndex: 0];
   NSString *documentsDirectoryPath = [cachesPath stringByAppendingPathComponent:@"music.mp3"];
  [receivedData writeToFile:documentsDirectoryPath atomically:YES];

Can I use like this?


回答1:


If you save the files to NSCacheDictionary you will not be able to retrieve them from itunes.

Edit: You can store the mp3 files to NSDocumentDirectory and set "do not backup" flag for setting the flag you can check the Technical Q&A QA1719.

For additional information you can check the docs.

specifically:

Use this attribute with data that can be recreated but needs to persist even in low storage situations for proper functioning of your app or because customers expect it to be available during offline use. This attribute works on marked files regardless of what directory they are in, including the Documents directory.



来源:https://stackoverflow.com/questions/11857837/can-i-save-the-downloaded-files-to-nscachedictionary-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!