Moving String extension to separate file

pull/2/head
Michael Scoff 7 years ago
parent 15fb33a4b3
commit de23d880cb
  1. 22
      Trust/Extensions/String.swift
  2. 2
      Trust/Payment/RequestViewController.swift
  3. 22
      Trust/Payment/SendViewController.swift

@ -14,3 +14,25 @@ extension Data {
return map { String(format: "%02hhx", $0) }.joined()
}
}
extension String {
func index(from: Int) -> Index {
return self.index(startIndex, offsetBy: from)
}
func substring(from: Int) -> String {
let fromIndex = index(from: from)
return substring(from: fromIndex)
}
func substring(to: Int) -> String {
let toIndex = index(from: to)
return substring(to: toIndex)
}
func substring(with r: Range<Int>) -> String {
let startIndex = index(from: r.lowerBound)
let endIndex = index(from: r.upperBound)
return substring(with: startIndex..<endIndex)
}
}

@ -83,7 +83,7 @@ class RequestViewController: UIViewController {
}
func changeQRCode(value: Int) {
let string = "ethereum:\(account.address)?value=\(value)"
let string = "ethereum:\(account.address.address)?value=\(value)"
DispatchQueue.global(qos: .background).async {
let image = self.generateQRCode(from: string)

@ -175,25 +175,3 @@ extension SendViewController: QRCodeReaderDelegate {
}
}
extension String {
func index(from: Int) -> Index {
return self.index(startIndex, offsetBy: from)
}
func substring(from: Int) -> String {
let fromIndex = index(from: from)
return substring(from: fromIndex)
}
func substring(to: Int) -> String {
let toIndex = index(from: to)
return substring(to: toIndex)
}
func substring(with r: Range<Int>) -> String {
let startIndex = index(from: r.lowerBound)
let endIndex = index(from: r.upperBound)
return substring(with: startIndex..<endIndex)
}
}

Loading…
Cancel
Save