NSAttributedString
-
Declaration
Swift
public extension NSAttributedString.Key -
Creates a mutable copy
Declaration
Swift
var asMutable: NSMutableAttributedString { get } -
Undocumented
Declaration
Swift
func addingAttributes(_ attributes: [NSAttributedString.Key : Any], to range: NSRange? = nil) -> NSAttributedString -
Enumerates block contents in given range.
Declaration
Swift
func enumerateContents(in range: NSRange? = nil) -> AnySequence<EditorContent>Parameters
rangeRange to enumerate contents in. Nil to enumerate in entire string.
-
Enumerates only inline content in given range.
Declaration
Swift
func enumerateInlineContents(in range: NSRange? = nil) -> AnySequence<EditorContent>Parameters
rangeRange to enumerate contents in. Nil to enumerate in entire string.
-
Returns in range of CharacterSet from this string.
Declaration
Swift
func rangeOfCharacter(from characterSet: CharacterSet) -> NSRange?Parameters
characterSetCharacterSet to search.
-
Full range of this attributed string.
Declaration
Swift
var fullRange: NSRange { get } -
Collection of all the attachments with containing ranges in this attributed string.
Declaration
Swift
var attachmentRanges: [AttachmentRange] { get } -
Range of given attachment in this attributed string.
Declaration
Swift
func rangeFor(attachment: Attachment) -> NSRange?Parameters
attachmentAttachment to find. Nil if given attachment does not exists in this attributed string.
-
Ranges of
CharacterSetin this attributed string.Declaration
Swift
func rangesOf(characterSet: CharacterSet) -> [NSRange]Parameters
characterSetCharacterSet to search.
-
Attributed substring in reverse direction.
Declaration
Swift
func reverseAttributedSubstring(from range: NSRange) -> NSAttributedString?Parameters
rangeRange for substring. Substring starts from location in range to number of characters towards beginning per length specified in range.
-
Gets the next range of attribute starting at the given location in direction based on reverse lookup flag
Declaration
Swift
func rangeOf(attribute: NSAttributedString.Key, startingLocation location: Int, reverseLookup: Bool = false) -> NSRange?Parameters
attributeName of the attribute to look up
locationStarting location
reverseLookupWhen true, look up is carried out in reverse direction. Default is false.
-
Gets the complete range of attribute at the given location. The attribute is looked up in both forward and reverse direction and a combined range is returned. Nil if the attribute does not exist in the given location
Declaration
Swift
func rangeOf(attribute: NSAttributedString.Key, at location: Int) -> NSRange?Parameters
attributeAttribute to search
locationLocation to inspect
-
Gets the value of attribute at the given location, if present.
Declaration
Swift
func attributeValue<T>(for attributeKey: NSAttributedString.Key, at location: Int) -> T?Parameters
attributeKeyName of the attribute
locationLocation to check
-
Alternative to
attributedSubstring(from:_).stringAvoids allocatingNSAttributedStringand all the attributes for that range, only to ignore the range.Declaration
Swift
func substring(from range: NSRange) -> String -
Searches for given text in string
Declaration
Swift
func reverseRange(of searchText: String, startingLocation: Int, isCaseInsensitive: Bool = true) -> NSRange?Parameters
searchTextText to search
startingLocationStarting location from which the text should be searched backwards
isCaseInsensitiveCase insensitive search. Defaults to
trueReturn Value
Range of search text, if found.
View on GitHub
NSAttributedString Extension Reference