Post

Replies

Boosts

Views

Activity

Reply to AsyncPublisher of KeyValueObservingPublisher doesn't work
This appears to be a bug in NSObject.KeyValueObservingPublisher. It's triggered because the values property only sends an initial Demand of .max(1) when it subscribes to the KVO publisher. Forcing a larger Demand works around the problem. We can use the handleEvents operator to send unlimited demand to the KVO publisher: Task { for await value in obj .publisher(for: \.count) .handleEvents(receiveSubscription: { $0.request(.unlimited) }) .values { print("async: \(value)") } }
Feb ’24
Reply to Associated Code?
actor ImageDownloader { private enum CacheEntry { case inProgress(Task.Handle<Image, Error>) case ready(Image) } private var cache: [URL: CacheEntry] = [:] func image(from url: URL) async throws -> Image? { if let cached = cache[url] { switch cached { case .ready(let image): return image case .inProgress(let handle): return try await handle.get() } } let handle = async { try await downloadImage(from: url) } cache[url] = .inProgress(handle) do { let image = try await handle.get() cache[url] = .ready(image) return image } catch { cache[url] = nil throw error } } }
Jun ’21
Reply to Emoji Ranger not showing in Add Widget list
It's not clear what either of these workarounds means. I don't understand how either of these workarounds is different than my normal process, or different than what's shown in the video. What does “Debug with your extension’s scheme directly to Simulator” mean? How is that different than what Izzy does in the video? Where in Xcode do we click to make it happen? What does “build the Widget's scheme directly”? How is that different than what he does in the video? Where in Xcode do we click to make it happen? Also, it sounds like the second “Frameworks Engineer” response doesn't understand the problem. The response talks about “automatically add the widget to the simulator's home screen”, but that is not the problem, for me at least. Following along with the video up to 6m12s works and automatically puts the small-family widget on the simulator's home screen, just as in the video. The problem is at 6m25s in the video, where Izzy opens the add sheet. In my simulator, the add sheet doesn't contain Emoji Rangers as a list item. Is there a workaround to get Emoji Rangers to show up in the add sheet? Here are some things which did not help: Launch the Emoji Rangers app (which gets added to the second page of the simulator's home screen). Remove the app and reinstalling it. Restart the simulator. Change the EmojiRangerWidgetExtension scheme's Executable from “Ask on Launch” to “EmojiRangerWidgetExtension.appex”. Simulator > Device > Restart Simulator > Device > Erase All Content and Settings… Quit and relaunch simulator.
Jun ’20