Skip to content

Instantly share code, notes, and snippets.

View VGraupera's full-sized avatar

Vidal Graupera VGraupera

View GitHub Profile
@VGraupera
VGraupera / gist:e9f81ecd6548d668bf97
Created February 17, 2015 16:20
Backup and restore to iCloud
def backup
error_ptr = Pointer.new(:object)
fileManager = NSFileManager.defaultManager
# iCloud
icloud = fileManager.URLForUbiquityContainerIdentifier(nil)
Logger.debug "iCloud at #{NSHomeDirectory().stringByAppendingPathComponent( "Documents/")}"
if icloud
icloud_url = icloud.URLByAppendingPathComponent("Documents/cd_backup.sqlite")
a = fileManager.startDownloadingUbiquitousItemAtURL(icloud_url, error:error_ptr)