Adding the “Do Not Backup” attribute to a folder hierarchy in iOS 5.0.1

后端 未结 6 894
遇见更好的自我
遇见更好的自我 2020-12-07 21:32

Referencing iCloud + Storage of media in iPhone Documents folder, which shows how to set the iOS 5.0.1 \"Do Not Backup\" attribute for a file.

Is there an efficient

6条回答
  •  既然无缘
    2020-12-07 22:05

    Correction on above method,use this for swift

     func addSkipBackupAttributeToItemAtURL(URL:NSURL) ->Bool {
    
        let fileManager = NSFileManager.defaultManager()
        assert(fileManager.fileExistsAtPath(URL.absoluteString!))
    
        var error:NSError?
        let success:Bool = URL.setResourceValue(NSNumber(bool: true),forKey: NSURLIsExcludedFromBackupKey, error: &error)
    
        if !success{
    
            println("Error excluding \(URL.lastPathComponent) from backup \(error)")
        }
    
        return success;
    }
    

提交回复
热议问题