mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
fix XCode config, add icons
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// StringExt.swift
|
||||
// NFCPassportReaderApp
|
||||
//
|
||||
// Created by Andy Qua on 30/06/2019.
|
||||
// Copyright © 2019 Andy Qua. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Some Utility methods for string - access characters by index
|
||||
extension String {
|
||||
subscript(_ i: Int) -> String {
|
||||
let idx1 = index(startIndex, offsetBy: i)
|
||||
let idx2 = index(idx1, offsetBy: 1)
|
||||
return String(self[idx1..<idx2])
|
||||
}
|
||||
|
||||
subscript (bounds: CountableRange<Int>) -> String {
|
||||
let start = index(startIndex, offsetBy: bounds.lowerBound)
|
||||
let end = index(startIndex, offsetBy: bounds.upperBound)
|
||||
return String(self[start..<end])
|
||||
}
|
||||
|
||||
subscript (bounds: CountableClosedRange<Int>) -> String {
|
||||
let start = index(startIndex, offsetBy: bounds.lowerBound)
|
||||
let end = index(startIndex, offsetBy: bounds.upperBound)
|
||||
return String(self[start...end])
|
||||
}
|
||||
|
||||
subscript (bounds: CountablePartialRangeFrom<Int>) -> String {
|
||||
let start = index(startIndex, offsetBy: bounds.lowerBound)
|
||||
return String(self[start...])
|
||||
}
|
||||
|
||||
func strip() -> String {
|
||||
let trimmed = self.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return trimmed
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user