void commitCurrentSnapshot(UIImage snapshotImage, string description, NSData gameData) { if (!CurrentSnapshotMetadata.IsOpen) { // Perhaps we could be harsher here and make this an assertion Console.WriteLine("Error trying to commit a snapshot. You must always open it first"); return; } var dataChange = new SnapshotMetadataChange(); dataChange.SnapshotDescription = description; // Done for simplicity, but this should really record the time since you last // opened a snapshot int millsSinceaPreviousSnapshotWasOpened = 10000; dataChange.PlayedTime = CurrentSnapshotMetadata.PlayedTime + millsSinceaPreviousSnapshotWasOpened; dataChange.CoverImage = new SnapshotMetadataChangeCoverImage(snapshotImage); CurrentSnapshotMetadata.Commit(dataChange, gameData, async delegate(SnapshotMetadata snapshotMetadata, NSError error) { if (error == null) { Console.WriteLine("Successfully saved {0}", snapshotMetadata); // Once our game has been saved, we should re-open it, so it's ready for saving again. LoadSnapshot(snapshotMetadata); } else { Console.WriteLine("Error while saving: {0}", error); } }); }
// - (void)readCurrentSnapshot { // [self.currentSnapshotMetadata readWithCompletionHandler:^(NSData *data, NSError *error) { // if (!error) { // NSLog(@"Successfully read %d blocks", (int) data.length); // self.inventory = [GCATStarInventory starInventoryFromCloudData:data]; // [self.screenViewController allDoneWithCloud]; // // } else { // NSLog(@"Error while loading snapshot data: %@", error); // NSLog(@"Error description: %@", [error description]); // } // }]; // } void readCurrentSnapshot() { CurrentSnapshotMetadata.Read(async delegate(NSData data, NSError error) { if (error == null) { Console.WriteLine("Successfully read {0} blocks", data.Length); Inventory = StarInventory.FromCloudData(data); ScreenViewController.AllDoneWithCloud(); } else { Console.WriteLine("Error while loading snapshot data: {0}", error); Console.WriteLine("Error description: {0}", error.Description); } }); }