AutocompleteManager

open class AutocompleteManager : NSObject, InputPlugin, UITextViewDelegate, UITableViewDelegate, UITableViewDataSource

Properties [Public]

  • A protocol that passes data to the AutocompleteManager

    Declaration

    Swift

    open weak var dataSource: AutocompleteManagerDataSource?
  • A protocol that more precisely defines AutocompleteManager logic

    Declaration

    Swift

    open weak var delegate: AutocompleteManagerDelegate?
  • A reference to the InputTextView that the AutocompleteManager is using

    Declaration

    Swift

    private(set) public weak var textView: UITextView? { get }
  • Declaration

    Swift

    public var inputTextView: InputTextView? { get }
  • An ongoing session reference that holds the prefix, range and text to complete with

    Declaration

    Swift

    private(set) public var currentSession: AutocompleteSession? { get }
  • The AutocompleteTableView that renders available autocompletes for the currentSession

    Declaration

    Swift

    open lazy var tableView: AutocompleteTableView { get set }
  • Adds an additional space after the autocompleted text when true. Default value is TRUE

    Declaration

    Swift

    open var appendSpaceOnCompletion: Bool
  • Keeps the prefix typed when text is autocompleted. Default value is TRUE

    Declaration

    Swift

    open var keepPrefixOnCompletion: Bool
  • Allows a single space character to be entered mid autocompletion.

    For example, your autocomplete is “Nathan Tannar”, the .whitespace deliminater set would terminate the session after “Nathan”. By setting maxSpaceCountDuringCompletion the session termination will disregard that number of spaces

    Default value is 0

    Declaration

    Swift

    open var maxSpaceCountDuringCompletion: Int
  • When enabled, autocomplete completions that contain whitespace will be deleted in parts. This meands backspacing on “@Nathan Tannar” will result in “ Tannar” being removed first with a second backspace action required to delete “@Nathan”

    Default value is TRUE

    Declaration

    Swift

    open var deleteCompletionByParts: Bool
  • The default text attributes

    Declaration

    Swift

    open var defaultTextAttributes: [NSAttributedString.Key : Any]
  • The NSAttributedString.Key.paragraphStyle value applied to attributed strings

    Declaration

    Swift

    public let paragraphStyle: NSMutableParagraphStyle
  • A block that filters the AutocompleteCompletion‘s sourced from the dataSource, based on the AutocompleteSession. The default function requires the AutocompleteCompletion.text string contains the AutocompleteSession.filter string ignoring case

    Declaration

    Swift

    open var filterBlock: (AutocompleteSession, AutocompleteCompletion) -> (Bool)

Properties [Private]

  • The prefices that the manager will recognize

    Declaration

    Swift

    public private(set) var autocompletePrefixes: Set<String> { get }
  • The delimiters that the manager will terminate a session with The default value is: [.whitespaces, .newlines]

    Declaration

    Swift

    public private(set) var autocompleteDelimiterSets: Set<CharacterSet> { get }
  • The text attributes applied to highlighted substrings for each prefix

    Declaration

    Swift

    public private(set) var autocompleteTextAttributes: <<error type>> { get }

Initialization

  • Declaration

    Swift

    public init(for textView: UITextView)

InputPlugin

  • Reloads the InputPlugin’s session

    Declaration

    Swift

    open func reloadData()
  • Invalidates the InputPlugin’s session

    Declaration

    Swift

    open func invalidate()
  • Passes an object into the InputPlugin’s session to handle

    Declaration

    Swift

    @discardableResult
    open func handleInput(of object: AnyObject) -> Bool

    Parameters

    object

    A string to append

API [Public]

  • Registers a prefix and its the attributes to apply to its autocompleted strings

    Declaration

    Swift

    open func register(prefix: String, with attributedTextAttributes: [NSAttributedString.Key : Any]? = nil)

    Parameters

    prefix

    The prefix such as: @, # or !

    attributedTextAttributes

    The attributes to apply to the NSAttributedString

  • Unregisters a prefix and removes its associated cached attributes

    Declaration

    Swift

    open func unregister(prefix: String)

    Parameters

    prefix

    The prefix such as: @, # or !

  • Registers a CharacterSet as a delimiter

    Declaration

    Swift

    open func register(delimiterSet set: CharacterSet)

    Parameters

    delimiterSet

    The CharacterSet to recognize as a delimiter

  • Unregisters a CharacterSet

    Declaration

    Swift

    open func unregister(delimiterSet set: CharacterSet)

    Parameters

    delimiterSet

    The CharacterSet to recognize as a delimiter

  • Replaces the current prefix and filter text with the supplied text

    Declaration

    Swift

    open func autocomplete(with session: AutocompleteSession)

    Parameters

    text

    The replacement text

  • Returns an attributed string with bolded characters matching the characters typed in the session

    Declaration

    Swift

    open func attributedText(matching session: AutocompleteSession,
                             fontSize: CGFloat = 15,
                             keepPrefix: Bool = true) -> NSMutableAttributedString

    Parameters

    session

    The AutocompleteSession to form an NSMutableAttributedString with

    Return Value

    An NSMutableAttributedString

UITextViewDelegate

UITableViewDataSource

UITableViewDelegate

  • Declaration

    Swift

    open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
  • If the autocomplete matches should be made by casting the strings to lowercase. Default value is FALSE DEPRICATED; will always return FALSE

    Declaration

    Swift

    @available(*, deprecated, message: "`isCaseSensitive` was replaced in favour of a more customizable `filterBlock: (String﹚ -> (Bool﹚`")
    public var isCaseSensitive: Bool { get set }