Read More
Read now

The Built – In Formatter types in iOS swift

Save

As per Apple Documentation, the definition of Formatter is “An abstract class that declares an interface for objects that create, interpret, and validate the textual representation of values”. We have already seen the most commonly used Formatter like DateFormatter and NumberFormatter. In this blog, we will look into some lesser-known Built-in Formatter.

1) MeasurementFormatter => It availability is from iOS 10. It provides localized representations of units and measurements. Let see an example of it.

 

In the above example, we have created the measurementFormatter method and after that, we have called it from viewDidLoad.

2) PersonNameComponentsFormatter => It availability is from iOS 9.0+. It provides localized representations of the components of a person’s name. So, this formatter will be useful whenever we have to parse and format a person’s name. Now we will see how to use this formatter.

Similarly, like measurementFormatter method, we have created an example method of personNameformatter. And called it from viewDidLoad.

3) RelativeDateTimeFormatter => It  creates locale-aware string representations of a relative date or time. Let see an example of it.

4) ByteCountFormatter => It converts a byte count value into a localized description that is set up with the appropriate byte modifier. Therefore it is useful whenever we need byte value into localized human readable form.

 

Thanks for reading this blog.

You can also check other blogs from here. if you have any issue or suggestion you can leave your query/suggestion in the comment section.

Reference

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!

Deniel Kerr

Owner and Founder. Opencart

Talk to Sales
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home