Format alternatives and similar libraries
Based on the "Text" category.
Alternatively, view Format alternatives based on common mentions on social networks and blogs.
-
PhoneNumberKit
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. -
TwitterTextEditor
A standalone, flexible API that provides a full-featured rich text editor for iOS applications. -
RichEditorView
DISCONTINUED. RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. -
Atributika
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement. -
Mustard
🌭 Mustard is a Swift library for tokenizing strings when splitting by whitespace doesn't cut it. -
PrediKit
An NSPredicate DSL for iOS, OSX, tvOS, & watchOS. Inspired by SnapKit and lovingly written in Swift. -
AttributedTextView
Easiest way to create an attributed UITextView (with support for multiple links and from html) -
OysterKit
OysterKit is a framework that provides a native Swift scanning, lexical analysis, and parsing capabilities. In addition it provides a language that can be used to rapidly define the rules used by OysterKit called STLR
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Format or a related project?
README
Format
A Swift formatter kit. Simple formatting syntax for decimal numbers, currency, mass, addresses, ordinal numbers and hexadecimal colors.
Usage
Import Format at the top of the Swift file with the content you would like to format.
import Format
Number Formatting
Format provides a formatting extension for all number types. To format an Int to two decimal places:
let formattedNumber = 45.format(Decimals.two) // 45.00
Format defaults to the user's current locale but a custom locale can be easily provided:
let frLocale = Locale(identifier: "FR")
let gbLocale = Locale(identifier: "GB")
let formattedFRNumber = 99.format(Currency.EUR, locale: frLocale) // 99,00 €
let formattedGBNumber = 99.format(Currency.GBP, locale: gbLocale) // £ 99.00
Apply any of these formatters to any number type:
Decimals.three // 10.123
Currency.USD // $10.12
General.ordinal // 10th (iOS9+ only)
General.spellOut // ten point one two three
General.distance // 30 feet
Mass.person // 67 kg
The distance formatter assumes the number represents the distance in meters before converting and formatting it to the current locale's preferred unit.
Address Formatting (iOS9.0+ only)
Different cultures have different ways of displaying addresses. Format includes an extension on CLPlacemark that converts the addressDictionary to a formatted string in the current locale:
let address = placemark.format()
Please note that this function will produce a deprecated warning when used. This is because Apple is using AddressBook keys in the CLPlacemark and AddressBook was deprecated.
To format a custom address (all fields are optional strings):
let address = AddressFormatter().format(street, city: city, state: state, postalCode: postalCode, country: country, ISOCountryCode: ISOCountryCode)
Color Formatting
Format can help you convert hexadecimal colors from the web to UIColors you can work with:
let color = ColorFormatter().format("2ba134")
In case of an error, the color will default to black if the string is empty or white if the string is invalid.
Setting up with Carthage
Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate Format into your Xcode project using Carthage, specify it in your Cartfile
:
github "marmelroy/Format"
Setting up with CocoaPods
source 'https://github.com/CocoaPods/Specs.git'
pod 'Format', '~> 0.5'