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
)
}
}
}
Post
Replies
Boosts
Views
Activity
This is very useful for testing: -AppleLocale en_US -AppleMetricUnits false/ -AppleMeasurementUnits Inches
@eskimo, where we can find documentation about this and other useful flags and launch arguments?
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?
using .share() instead of a .print() does the same trick for me.
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?
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