Posts

Post not yet marked as solved
0 Replies
167 Views
Hey, I can't find any official information anywhere, maybe someone stumbled upon it, but from my observation, using the #Preview macro bypasses code coverage, which means you don't have to artificially bypass it if you care about a high percentage.
Posted
by miltenkot.
Last updated
.
Post not yet marked as solved
3 Replies
429 Views
Hello, I have an issue with formatting text in a TextField. I want to maintain formatting to two decimal places and have it respond to changes in the device's settings, as it currently does. However, I want to get rid of the problem with deleting the first character, which for some reason cannot be empty even though it should start with an empty value. This is my code extension Formatter { static let numberFormatter: NumberFormatter = { let formatter = NumberFormatter() formatter.currencyCode = "GBP" formatter.currencySymbol = "" formatter.minimumFractionDigits = 2 formatter.maximumFractionDigits = 2 formatter.zeroSymbol = "" return formatter }() } struct HomeView: View { @FocusState private var isFocused: Bool @State var value: Double = 0 var body: some View { VStack { TextField("0.0", value: $value, formatter: Formatter.numberFormatter) .focused($isFocused) .border(.red) .keyboardType(.decimalPad) .toolbar { ToolbarItemGroup(placement: .keyboard) { if isFocused { Spacer() Button("Done") { isFocused = false } } } } } } } and here is the issue gif I found similar problems in other forums like in https://www.hackingwithswift.com/forums/swiftui/textfield-with-initial-empty-value-for-a-number/12486/15516 but unfortunately uncomment.
Posted
by miltenkot.
Last updated
.
Post not yet marked as solved
0 Replies
381 Views
Hey, I'm learning Instruments (Xcode 15.1), and I've encountered a situation for which I haven't found an answer yet. I have an application that loads 12 large images, with the last one taking the most space at 147MB. Instruments on the iOS 15 simulator correctly shows 21 allocations, as in the example from the book, because the last image is split into smaller parts due to poor optimization. But if I run the same example on the iOS 17 simulator, I have even fewer allocations than loaded images. And my question is whether memory allocation for large images is handled differently in iOS 17, or where can I read more about it?
Posted
by miltenkot.
Last updated
.