Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apps must follow the iOS Data Storage Guidelines or they will be rejected

i have developed an app that can download mp3 files (nearly 6 to 8 mb of size) from online and stored in NSDocumentDirectory. my app get rejected today and says that

"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. "

i used to store the music files in NSDocumentDirectory . so, this is the first time am doing this, i cant figure out the actual problem. what should i do to resubmit my app for acception.

here is my code

 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];

really need some help.

like image 924
neerajPK Avatar asked Dec 05 '22 15:12

neerajPK


1 Answers

i got my app rejected for the same reason , the solution is really simple instead of saving your downloaded files to the Documents directory you have to save them to the Cache directory which is a temp directory that don't get backed up to iCloud and can be randomly deleted by the OS on certain occasions ... this is how you save a file to the cache directory

NSString *filePath = [[self applicationCachesDirectory] stringByAppendingPathComponent:fileName];


BOOL flag = [[NSFileManager defaultManager] createFileAtPath:filePath contents: receivedData attributes:nil];

EDIT

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");
like image 133
ahmad Avatar answered Jan 18 '23 13:01

ahmad