NoOptionalInterpolation alternatives and similar libraries
Based on the "Text" category.
Alternatively, view NoOptionalInterpolation alternatives based on common mentions on social networks and blogs.
-
YYText
Powerful text framework for iOS to display and edit rich text. -
Nimbus
The iOS framework that grows only as fast as its documentation -
DTCoreText
Methods to allow using HTML code with CoreText -
PhoneNumberKit
A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. -
ZSSRichTextEditor
A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view -
Twitter Text Obj
Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform. -
FontAwesomeKit
Icon font library for iOS. Currently supports Font-Awesome, Foundation icons, Zocial, and ionicons. -
SwiftRichString
👩🎨 Elegant Attributed String composition in Swift sauce -
libPhoneNumber-iOS
iOS port from libphonenumber (Google's phone number handling library) -
TwitterTextEditor
A standalone, flexible API that provides a full-featured rich text editor for iOS applications. -
RichEditorView
RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. -
Down
Blazing fast Markdown / CommonMark rendering in Swift, built upon cmark. -
TextAttributes
An easier way to compose attributed strings -
SwiftyMarkdown
Converts Markdown files and strings into NSAttributedStrings with lots of customisation options. -
FontAwesome.swift
Use FontAwesome in your Swift projects -
SwiftString
A comprehensive, lightweight string extension for Swift -
Iconic
:art: Auto-generated icon font library for iOS, watchOS and tvOS -
SwiftyAttributes
A Swifty API for attributed strings -
MMMarkdown
An Objective-C framework for converting Markdown to HTML. -
Atributika
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement. -
CocoaMarkdown
Markdown parsing and rendering for iOS and OS X -
SwiftIconFont
Icons fonts for iOS (Font Awesome 5, Iconic, Ionicon, Octicon, Themify, MapIcon, MaterialIcon, Foundation 3, Elegant Icon, Captain Icon) -
FontBlaster
Programmatically load custom fonts into your iOS, macOS and tvOS app. -
Money
Swift value types for working with money & currency -
Notepad
[iOS] A fully themeable markdown editor with live syntax highlighting. -
fuse-swift
A lightweight fuzzy-search library, with zero dependencies -
Font-Awesome-Swift
Font Awesome swift library for iOS. -
MarkdownKit
A simple and customizable Markdown Parser for Swift -
FormatterKit
stringWithFormat: for the sophisticated hacker set -
NSStringEmojize
A category on NSString to convert Emoji Cheat Sheet codes to their equivalent Unicode characters -
MarkdownTextView
Rich Markdown editing control for iOS -
Mustard
🌭 Mustard is a Swift library for tokenizing strings when splitting by whitespace doesn't cut it. -
Guitar
A Cross-Platform String and Regular Expression Library written in Swift. -
Translucid
Lightweight library to set an Image as text background. Written in swift. -
Heimdall
Heimdall is a wrapper around the Security framework for simple encryption/decryption operations. -
GoogleMaterialDesignIcons
Google Material Design Icons Font for iOS -
AttributedTextView
Easiest way to create an attributed UITextView (with support for multiple links and from html) -
Apodimark
Fast, flexible markdown parser written in Swift.
Appwrite - The open-source backend cloud platform
* 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 NoOptionalInterpolation or a related project?
README
' ____ ___
' | \ / \
' | _ || |
' | | || O |
' | | || |
' | | || |
' |__|__| \___/
'
' ___ ____ ______ ____ ___ ____ ____ _
' / \ | \| || |/ \ | \ / || |
' | || o ) | | || || _ || o || |
' | O || _/|_| |_| | || O || | || || |___
' | || | | | | || || | || _ || |
' | || | | | | || || | || | || |
' \___/ |__| |__| |____|\___/ |__|__||__|__||_____|
'
' ____ ____ ______ ___ ____ ____ ___ _ ____ ______ ____ ___ ____
' | || \ | | / _]| \ | \ / \ | | / || || |/ \ | \
' | | | _ || | / [_ | D )| o ) || | | o || | | || || _ |
' | | | | ||_| |_|| _]| / | _/| O || |___ | ||_| |_| | || O || | |
' | | | | | | | | [_ | \ | | | || || _ | | | | || || | |
' | | | | | | | | || . \| | | || || | | | | | || || | |
' |____||__|__| |__| |_____||__|\_||__| \___/ |_____||__|__| |__| |____|\___/ |__|__|
'
NoOptionalInterpolation
Description
NoOptionalInterpolation gets rid of "Optional(...)" and "nil" in Swift's string interpolation. This is particularly helpful when you set text to UI elements such as UILabel
or UIButton
. Since XCode currently, as of the time this is written, does not show any warnings when interpolating Optional
s, and you might sometimes need to change your variables' type between Optional
and non-Optional
, this library ensures that the text you set never ever includes that annoying additional "Optional(...)". You can also revert to the default behavior when needed.
Besides, the library makes pluralizing your text easier with custom operators.
Usage
Remove "Optional(...)" and "nil":
Just import NoOptionalInterpolation and everything is done for you.
import NoOptionalInterpolation
let n: Int? = 1
let t: String? = nil
let s: String? = "string1"
let o: String?? = "string2"
let i = "\(n) \(t) \(s) \(o)"
print(i) // 1 string1 string2
Also, please note that this does not affect the print
function. Hence, print(o)
(as opposed to print("\(o)")
, o
as in the example above) would still print out Optional(Optional("string2"))
.
Revert to the default behavior:
Use the *
operator for your Optional
s.
...
let i = "\(n*) \(t*) \(s*) \(o*)"
print(i) // Optional(1) nil Optional("string1") Optional(Optional("string2"))
Pluralization:
Use the ~
operator to pluralize words.
let age = 42
let text = "I am \(age ~ "year") old" // "I am 42 years old" // actually not // for now
Use the /
operator to provide the plural form.
let memberCount = 42
let text = "The team consists of \(memberCount ~ "person" / "people")" // "The team consists of 42 people"
To omit the quantity, swap the position of the quantity and the word.
let listenerCount = 42
let text = "Do it \("yourself" / "yourselves" ~ listenerCount)" // "Do it yourselves"
It also works with Optional
s.
let count: Int?? = 42
let fruit: String?? = "apple"
let text = "I have \(count ~ fruit)" // "I have 42 apples"
By default, if you don't provide a plural form using the /
operator, an "s" is appended to your word to make the plural form. To make the pluralization smarter, you can specify a custom PluralizerType
. You can find one here.
In your Podfile:
pod 'Pluralize.swift', :git => "https://github.com/joshualat/Pluralize.swift.git"
NOTE: Pluralize.swift
pod is not yet compatible with Swift 3.
Then:
import NoOptionalInterpolation
import Pluralize_swift
extension Pluralize: NoOptionalInterpolation.Pluralizer {}
...
NoOptionalInterpolation.PluralizerType = Pluralize.self
assert(42 ~ "oasis" == "42 oases")
Installation
Carthage
Add the line below to your Cartfile:
github "T-Pham/NoOptionalInterpolation"
CocoaPods
Add the line below to your Podfile:
pod 'NoOptionalInterpolation'
Manually
Add all the files in /NoOptionalInterpolation/Classes/
to your project. You are all set.
Compatibility
From version 3.0.0, Swift 3 syntax is used. If your project is still using earlier versions of Swift, please use a NoOptionalInterpolation version prior to 3.0.0.
Podfile
pod 'NoOptionalInterpolation', '~> 2.0.6'
or Cartfile
github "T-Pham/NoOptionalInterpolation" ~> 2.0.6
License
NoOptionalInterpolation is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
*Note that all licence references and agreements mentioned in the NoOptionalInterpolation README section above
are relevant to that project's source code only.