@propertyWrapper: Encoding Strings to Valid URL Characters

With this @propertyWrapper code snippet you will be able to wrap String values into wrapped values of url safe characters.

@propertyWrapper: Encoding Strings to Valid URL Characters

Porperty wrappers serve as a new type to wrap properties and add additional logic if needed. It's part of Swift since version 5.1 and can be useful to validate values woth a set of rules or tranform values to match certain requirements etc.

As a simple example, you might want to ensure that String is using upper case, for example to correctly describe the abbreviation of federal states in the U.S. like California (CA) or New York (NY) or you could ensure that a url provided as a String includes only valid url characters.

Become a free member or log in to proceed.