Where to save the local DB created for iphone app?

谁说我不能喝 提交于 2020-01-24 12:55:05

问题


I have developed a app that loads fully static content . I am storing data more than 4 mb of size. With out this content the app will not work. In my case where should i save the local database(documents folder or library folder).

My app got rejected since it was backed up for iCloud storage.

1) Where should i save the database? In Library folder or inside Documents folder?

2) Since apple rejected my app i believe that I should not backup the database for iCloud. Please correct me if i was wrong.

3) In my app i am also taking screen shot and saving in document directory to attach it in mail. Whether can i save the screen shot in document directory or should i save it the caches folder? Please update.

Please guide me the right way to implement DB .

Thanks


回答1:


Please use below code in your application before saving database to your document directory..

-(BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    const char* filePath = [[URL path] fileSystemRepresentation];

    const char* attrName = "com.apple.MobileBackup";
    u_int8_t attrValue = 1;

    int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);

//  NSLog(@"Attributs : %d and Path : %@",result,URL);
    if (result != 0) { 

        NSLog(@"File Backup Attribute setting error");

    }

    return result == 0;
}


来源:https://stackoverflow.com/questions/16767861/where-to-save-the-local-db-created-for-iphone-app

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