Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AppmethodCode SnippetDelphiFiremonkeyIOS

Exclude Files From The Icloud Backup With This Code In #Delphi XE8 Firemonkey On #IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE8 Firemonkey Icloud Backup Flag Apple IOS | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

If you are deploying files with your Delphi XE8 Firemonkey apps to IOS in the Startup\Documents directory and you do not want or need them backed up to Icloud there is a code snippet you can use to turn off the backup flag. I found this code over on the German Delphi forum. The flag under IOS is called NSURLIsExcludedFromBackupKey and the Apple docs are here. You can find out more about when and how you should use this no backup flag over on StackOverflow. One example of usage is if you have a large SQLite file that you are deploying with the app and you have no need for it to backup to Icloud then you can apply this flag to the file when your app is run for the first time. This code snippet should also work with Appmethod. Here is the code snippet:
uses iOSapi.Foundation;

function SetBackupFlag(AFileName: string; ABackup: boolean): boolean;
var
URL : NSUrl;
Err : PPointer;
begin
URL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(NSStr(AFileName)));
result := URL.setResourceValue(TNSNumber.OCClass.numberWithBool(not ABackup), NSStr('NSURLIsExcludedFromBackupKey'), err) and (err = nil);
end;

Head over and check out the full forum thread in German about the backup flag code for Delphi Firemonkey on IOS.

close

Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
DelphiFiremonkeyShowcaseWindows

How To Build Stable Diffusion Text To Image Prompts

AndroidC++BuilderDelphiFiremonkeyIOSOSXWindows

FireMonkey 10.4.2 Features Updated iOS 14, Android 11, And macOS 11 Support Plus Hundreds Of Fixes

DelphiIDEShowcaseWindows

Ryzen 9 5950x: One Billion Lines Of Delphi Code Compiled In ~5 Minutes On 16 Cores

DelphiFiremonkeyIDEIOSOSXWindows

DelphiCon 2020 FireMonkey Sessions Available Starting November 19

Sign up for our Newsletter and
stay informed

1 Comment

Leave a Reply to Dennis Cancel reply