iCloud + Storage of media in iPhone Documents folder

前端 未结 2 1690
滥情空心
滥情空心 2020-12-15 09:26

I, like many developers, got an email from Apple recently that stated we should move our data from the documents directory into another folder to permit more streamlined bac

2条回答
  •  不知归路
    2020-12-15 10:12

    iOS 5.0.1 introduced a flag to address this issue:

    https://developer.apple.com/library/ios/#qa/qa1719/_index.html

    Their recommendation is to create a folder in /Library/ like /Library/PrivateDocs , and put your files there. However you will also have to set a "do not backup" flag on them as every file in /Library except for those in /Library/Cache or tmp are backed up by default. Set the flag on PrivateDocs folder with this command:

    #include 
    - (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);
        return result == 0;
    }
    

提交回复
热议问题