Skip to content

Latest commit

History

History
190 lines (125 loc) 路 2.6 KB

File metadata and controls

190 lines (125 loc) 路 2.6 KB

EXTENSION

String

public extension String

Properties

removeHTML

var removeHTML: String

Remove HTML tags from String

isEmail

var isEmail: Bool

Is valid email

areNumbers

var areNumbers: Bool

Are numbers 0-9

toInt

var toInt: Int?

Cast to Int

toDouble

var toDouble: Double?

Cast to Double

trimmingZeroDecimal

var trimmingZeroDecimal: String

Trimming ".0"

addingPlusSymbol

var addingPlusSymbol: String

Adding "+" at the very beginning.

addingMinusSymbol

var addingMinusSymbol: String

Adding "-" at the very beginning.

uppercasingFirstLetter

var uppercasingFirstLetter: String

lowercasingFirstLetter

var lowercasingFirstLetter: String

isBlank

var isBlank: Bool

Return true if self is empty or only contains white spaces and/or new lines.

isVisible

var isVisible: Bool

Return false if self is empty or only contains white spaces and/or new lines.

nilIfBlank

var nilIfBlank: String?

Return nil if self.isBlank is true.

Methods

trim()

func trim() -> String

Trim white space and new lines

layoutSize(with:)

func layoutSize(with font: UIFont) -> CGSize

Returns the CGSize that the string being layout on screen.

  • Parameter font: The given font.
  • Returns: The result CGSize.

Parameters

Name Description
font The given font.

advanceNumberValue(step:)

mutating func advanceNumberValue(step: Int = 1)

Cast as Int and add the given value. No changes if casting fails.

isOldAppVersion(comparedWith:)

func isOldAppVersion(comparedWith aVersion: String) -> Bool

Comparing app versions. Returns true if self is 1.1.0 and the given value is 1.2.0.

  • Parameter aVersion: Another version.
  • Returns: true if the give version is newer than self.

Parameters

Name Description
aVersion Another version.

treatsVisuallyEmptyAsNil()

func treatsVisuallyEmptyAsNil() -> String?

slice(from:to:)

func slice(from: String, to: String) -> String?

Get subscring from created range

  • Parameters:
    • from: from String
    • to: to String
  • Returns: String

Parameters

Name Description
from from String
to to String

copyToPasteboard()

func copyToPasteboard()

Copy self to UIPasteboard