With 4D v17 R3, we introduced basic data formatters for dates, percentage, time, etc. 4D v17 R4 takes things a step further by providing you the ability to create your own data formatters and use them directly from the Project Editor.
In the 4D for iOS documentation, you’ll find a new Create data formatter chapter in the Data formatter section. It describes the entire process of data formatter creation. The easiest way to create your own formatter is to modify an existing example. For this, a Starter Project is available to help you build formatters to best suit your needs!
On the left below is an image of what we have before applying our formatters. The image on the right shows the result we want to achieve:
What changed ?
In this example we converted:
- 1- integer enumeration into string for the job field: 3 becomes “Product Owner”
- 2- integer enumeration into image for status field:1 becomes the “in progress” status icon
- 3- text enumeration into string for the country field: FRA becomes “France”
- 4- text enumeration into image for manager field: Eric becomes the “Eric’s profile” picture
The data formatter creation process is quite simple and allows you to add a new dimension to your apps just by using JSON files.