nee*_*jPK 4 data-storage ipad ios
我开发了一个应用程序,可以从在线下载MP3文件(大约6至8 MB的大小)并存储在NSDocumentDirectory中.我的应用程序今天被拒绝并说出来
"Apps must follow the iOS Data Storage Guidelines or they will be rejected"
We found that your app does not follow the iOS Data Storage Guidelines, which is
required per the App Store Review Guidelines. The iOS Data Storage Guidelines
indicate that only content that the user creates using your app, e.g., documents,
new files, edits, etc., may be stored in the /Documents directory - and backed up
by iCloud.
Temporary files used by your app should only be stored in the /tmp directory;
please remember to delete the files stored in this location when the user exits
the app. "
Run Code Online (Sandbox Code Playgroud)
我曾经将音乐文件存储在NSDocumentDirectory中.所以,这是我第一次这样做,我无法弄清楚实际问题.我该怎么做才能重新提交我的应用程序以进行接受.
这是我的代码
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [[paths objectAtIndex:0]stringByAppendingPathComponent:[NSString stringWithFormat:@"psalmsMusic%d.mp3",i]];
NSLog(@"ddddddd psalmsMusic%d.mp3",i);
i++;
NSLog(@"path %@",documentsDirectoryPath);
[receivedData writeToFile:documentsDirectoryPath atomically:YES];
Run Code Online (Sandbox Code Playgroud)
真的需要一些帮助.
由于同样的原因,我的应用程序被拒绝,解决方案非常简单,而不是将下载的文件保存到Documents目录,您必须将它们保存到Cache目录,这是一个临时目录,无法备份到iCloud并且可以在某些情况下由操作系统随机删除...这是将文件保存到缓存目录的方式
NSString *filePath = [[self applicationCachesDirectory] stringByAppendingPathComponent:fileName];
BOOL flag = [[NSFileManager defaultManager] createFileAtPath:filePath contents: receivedData attributes:nil];
Run Code Online (Sandbox Code Playgroud)
编辑
NSString *filePath = [[self applicationCachesDirectory] stringByAppendingPathComponent:[NSString stringWithFormat:@"psalmsMusic%d.mp3",i]];
NSLog(@"ddddddd psalmsMusic%d.mp3",i);
i++;
BOOL flag = [[NSFileManager defaultManager] createFileAtPath:filePath contents: receivedData attributes:nil];
if ( flag )
NSLog("success");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6547 次 |
| 最近记录: |