d
This commit is contained in:
@@ -7,10 +7,11 @@ enum MeetupId {
|
|||||||
case meetupIdTextUI
|
case meetupIdTextUI
|
||||||
}
|
}
|
||||||
|
|
||||||
static func shouldFormat(_ s: String) -> String? {
|
static func onlyFormat(_ s: String) -> String? {
|
||||||
let digits = s.components(separatedBy: NSCharacterSet.decimalDigits.inverted).reduce("") { $0 + $1 }
|
let digits = s.components(separatedBy: NSCharacterSet.decimalDigits.inverted).reduce("") { $0 + $1 }
|
||||||
var r = ""
|
var r = ""
|
||||||
var i = 0
|
var i = 0
|
||||||
|
// Делим каждые три цифры дефисом.
|
||||||
for v in digits {
|
for v in digits {
|
||||||
r += String(v)
|
r += String(v)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
@@ -18,6 +19,7 @@ enum MeetupId {
|
|||||||
r += "-"
|
r += "-"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Исключаем дефис в конце.
|
||||||
if r.hasSuffix("-") {
|
if r.hasSuffix("-") {
|
||||||
r = String(r.dropLast(1))
|
r = String(r.dropLast(1))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ final class VM: ObservableObject {
|
|||||||
let format = Bus.Processor(
|
let format = Bus.Processor(
|
||||||
MeetupId.K.meetupIdTextUI.rawValue,
|
MeetupId.K.meetupIdTextUI.rawValue,
|
||||||
MeetupId.K.meetupIdTextApp.rawValue,
|
MeetupId.K.meetupIdTextApp.rawValue,
|
||||||
MeetupId.shouldFormat
|
MeetupId.onlyFormat
|
||||||
)
|
)
|
||||||
var subscriptions = [AnyCancellable]()
|
var subscriptions = [AnyCancellable]()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user