File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -420,6 +420,16 @@ public func CRUUIDString() -> String {
420420 return NSUUID ( ) . uuidString
421421}
422422
423+ // MARK: - timer
424+
425+ public func CRStopTimer( _ tmr: Timer ? ) {
426+ if let timer = tmr {
427+ if timer. isValid {
428+ timer. invalidate ( )
429+ }
430+ }
431+ }
432+
423433// MARK: - GCD
424434
425435public func CRRunOnMainThread( task: @escaping CRVoidBlock ) {
Original file line number Diff line number Diff line change @@ -124,6 +124,26 @@ extension String {
124124 return result
125125 }
126126
127+ @discardableResult
128+ public func safeRemoveFirst( _ k: Int = 1 ) -> String {
129+ if count < k {
130+ return self
131+ }
132+ var result = self
133+ result. removeFirst ( k)
134+ return result
135+ }
136+
137+ @discardableResult
138+ public func safeRemoveLast( _ k: Int = 1 ) -> String {
139+ if count < k {
140+ return self
141+ }
142+ var result = self
143+ result. removeLast ( k)
144+ return result
145+ }
146+
127147 @discardableResult
128148 public func retainDecimal( _ digits: Int ) -> String {
129149 let formatter = NumberFormatter ( )
You can’t perform that action at this time.
0 commit comments