Can I add the Do not Back up for the “Document Directory” for iCloud

前端 未结 4 1794
长情又很酷
长情又很酷 2021-01-07 02:24

I had read that I can mark folders with \"do not backup\" attribute with ios 5.1 and later

As i understand, in such case all contents of directory will be excluded f

4条回答
  •  不思量自难忘°
    2021-01-07 03:22

        func addSkipBackupAttributeToItemAtURL(filePath:String) -> Bool
    
    {
        let URL:NSURL = NSURL.fileURLWithPath(filePath)
        assert(NSFileManager.defaultManager().fileExistsAtPath(filePath), "File \(filePath) does not exist")
        var success: Bool
        do {
            try URL.setResourceValue(true, forKey:NSURLIsExcludedFromBackupKey)
            success = true
        } catch let error as NSError {
            success = false
            print("Error excluding \(URL.lastPathComponent) from backup \(error)");
        }
        return success
    }
    

提交回复
热议问题