QRCode

open class QRCode

QRCode abstraction and generator.

  • Error correct level.

    Declaration

    Swift

    public let correctLevel: QRErrorCorrectLevel
  • If the image codes has a border around its content.

    Declaration

    Swift

    public let hasBorder: Bool
  • Construct a QRCode instance.

    Throws

    see QRCodeError

    Warning

    Is computationally intensive.

    Declaration

    Swift

    public convenience init(
        _ text: String,
        encoding: String.Encoding = .utf8,
        errorCorrectLevel: QRErrorCorrectLevel = .H,
        withBorder hasBorder: Bool = true
    ) throws

    Parameters

    text

    content of the QRCode.

    encoding

    encoding used for generating data from text.

    errorCorrectLevel

    error correct level, defaults to high.

    hasBorder

    if the image codes has a border around, defaults and suggests to be true.

  • Construct a QRCode instance.

    Throws

    see QRCodeError

    Declaration

    Swift

    public init(
        _ data: Data,
        errorCorrectLevel: QRErrorCorrectLevel = .H,
        withBorder hasBorder: Bool = true
    ) throws

    Parameters

    data

    raw content of the QRCode.

    errorCorrectLevel

    error correct level, defaults to high.

    hasBorder

    if the image codes has a border around, defaults and suggests to be true.

  • QRCode in binary form.

    Declaration

    Swift

    open private(set) lazy var imageCodes: [[Bool]] { get set }
  • Convert QRCode to String.

    Declaration

    Swift

    open func toString(filledWith black: Any,
                       patchedWith white: Any) -> String

    Parameters

    black

    recommend to be “\u{1B}[7m ” or “##”.

    white

    recommend to be “\u{1B}[0m ” or “ ”.

    Return Value

    a matrix of characters that is scannable.