I am new to swift and coped-pasted some code but it does not compile and I don't understand why and can't figure out why.
// ObservableObject that limits text fields to numbers (digits) only
class NumbersOnly: ObservableObject {
@Published var value = "" {
didSet {
let filtered = value.filter { $0.isNumber }
if value != filtered {
value = filtered
}
}
}
}
The code is on github here: DeliveryBox/MobileApp/DeliveryBox_iOS/DeliveryBox_iOS/ContentView.swift at main · RobertPHeller/DeliveryBox · GitHub
I have an "old" MacBook (2013 vintage, running MacOS 10.15.8), with XCode 12.4 (Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28). (I know this is old, but it is what I have and I really can't afford to buy a new Mac, esp. since I am not really a mac user.)