Refactor task usage and profile auto update
This commit is contained in:
@@ -9,3 +9,21 @@ public extension Binding {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public extension Binding where Value == Int32 {
|
||||
func stringBinding(defaultValue: Int32) -> Binding<String> {
|
||||
return Binding<String> {
|
||||
var intValue = wrappedValue
|
||||
if intValue == 0 {
|
||||
intValue = defaultValue
|
||||
}
|
||||
return String(intValue)
|
||||
} set: { newValue in
|
||||
var newIntValue = Int32(newValue) ?? defaultValue
|
||||
if newIntValue == 0 {
|
||||
newIntValue = defaultValue
|
||||
}
|
||||
wrappedValue = newIntValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user