INI Files on iOS

Posted by on in Blogs
I am currently recording part of tomorrows iOS Summer School and showing how to access and use INI Files on an iOS device. INI Files are great and have been around for a long time. Even though the fashion at times has been to switch to XML files as they can handle more complex structures, INIFiles, due to their ease of use and simplicity they have always been a great option.

Using INI Files hasn't changed, If you have used them before on Window or Mac with FireMonkey or on Windows with VCL/Console application, the same code will still work on iOS. The only thing you need to do is know where to store them and provide the appropriate file path.

The best location is the 'Documents' folder on iOS. This protects you from them being deleted when/if the Cache folder is cleared. The 'Documents' folder should be used only for files that are not recreate-able from the application (e.g. Databases etc) For files that are downloaded you can use the Library/Cache folder. An example often stated is if you do download files, then you can keep a link to the URL (to refetch them if cleared) in Documents folder, but the downloaded file should be in the Cache folder. An INI file may well be a good choice for this, but is not the only choice. Other options we will look at tomorrow on episode 4 of the Summer School will include local in memory data sets like TClientDataSet or a local database like SQLLite or Embarcadero's iOS Embedable Database InterBase ToGo or the free InterBase Lite (IBLite)*.

[caption id="attachment_390" align="alignnone" width="500" caption="Example of using an INI File"]Example of using an INI File[/caption]

The sample for the INI file, which includes code to show how to list all files in your application folder is available from code central at http://cc.embarcadero.com/item/29501
*IBLite license is inclided free with specific editions of Embarcadero Developer Tools


About
Gold User, Rank: 19, Points: 169
Product Marketing Manager & Associate Product Manager, InterBase. @DelphiABall

Comments

Check out more tips and tricks in this development video: