Post

Replies

Boosts

Views

Activity

Reply to ScrollView shrink to fit
we are using solution proposed here: https://github.com/onmyway133/blog/issues/769#issue-802788982 import SwiftUI struct HSearchBar: View { @State private var scrollViewContentSize: CGSize = .zero var body: some View { HStack { searchButton ScrollView(.horizontal, showsIndicators: false) { HStack(spacing: 12) { ForEach(store.collections) { collection in collectionCell(collection) } } .background( GeometryReader { geo -> Color in DispatchQueue.main.async { scrollViewContentSize = geo.size } return Color.clear } ) } .frame( maxWidth: scrollViewContentSize.width ) } } }
Jun ’21
Reply to Launch argument "-AppleLocale en_US" doesn't change measurement system(units) to "US" on MacOs
This link comes on top when searching for AppleMetricUnits https://opensource.apple.com/source/CF/CF-855.17/CFLocale.c.auto.html CFTypeRef pref = CFDictionaryGetValue(locale-_prefs, CFSTR("AppleMetricUnits")); if (pref) { us = (kCFBooleanFalse == pref); done = true; } else { pref = CFDictionaryGetValue(locale-_prefs, CFSTR("AppleMeasurementUnits")); if (pref) { us = CFEqual(pref, CFSTR("Inches")); done = true; } } and it seems the code is expecting boolean value for AppleMetricUnits key. How is false/ which seems XML becomes a boolean? What is the correct way to pass booleans as launch arguments?
May ’21
Reply to tryCatch followed by retry creates a retain cycle?
Here in your example: swift URLSession.shared .dataTaskPublisher(for: URL(string: "https://www.apple.com/")!) .tryCatch { _ in URLSession.shared .dataTaskPublisher(for: URL(string: "https://www.example.com/")!) } .retry(1) .map { String(decoding: $0.data, as: UTF8.self) } .sink( receiveCompletion: { print("completed \($0)") }, receiveValue: { print("value \($0)") }) .store(in: &cancellables) I see the leak of Combine.Publishers.Retry and Combine.Publishers.TryCatch every time this code runs through the successful path. I've tried the failure path by changing apple.com to zapple.com - a non-existing domain, leak still appears. Looks like retry is source of the leak and tryCatch is the cause of it. When I remove retry or .tryCatch - no leaks. Is this a Combine bug or incorrect use of Combine?
Mar ’21
Reply to tryCatch followed by retry creates a retain cycle?
Even simpler version:         CurrentValueSubjectString,Error("apple")             .tryCatch { _ in                 CurrentValueSubjectString,Error("pear")             }             .retry(1)             .sink(                 receiveCompletion: { print("completed \($0)") },                 receiveValue: { print("value \($0)") })             .store(in: &cancellables) leaks the same
Mar ’21