Archive for October 12, 2021

Tuesday, October 12, 2021 [Tweets] [Favorites]

Download Progress With Awaited Network Tasks

Soroush Khanlou:

One would think the URLSessionTaskDelegate would have some affordance that calls you back when new bytes come in, but if that exists, I couldn’t find it.

However, iOS 15 brings a new API that can be used for this purpose — a byte-by-byte asynchronous for loop that can do something every time a new byte comes in from the network — called AsyncBytes.

[…]

One question that this API raises: why does it call your block with every byte? The (very) old NSURLConnectionDelegate would give you updates with chunks of data, so why the change?

[…]

I think this example highlights something important about this new API. The file I was trying to download was about 20MB. That means my for loop is going to spin 20 million times. Because of that, it’s extremely sensitive to any slow tasks that take place in the loop.

[…]

The last thing I did, which did work, is to keep a local variable for the progress, and then only update the progress in SwiftUI when the fastRunningProgress had advanced by a percent.

Joseph Lord:

For the record AsyncSequence blazing fast in beta 5. 🏎❤️ Quicker to XOR the bytes in the file with AsyncSequence of bytes than to Data(contentsOf:) and iterate over the unsafe bytes

David Smith:

I think one of the biggest things people are going to be startled by in my async Swift code is how often I write async functions that aren’t (usually) asynchronous. It took me a few months and some advice from a coworker to internalize how useful this is.

[…]

The most obvious case this is useful is if you have some sort of cache: check the cache, if you hit do the thing immediately, if you miss, suspend and do the thing once you’ve loaded what you needed into the cache.

David Smith:

For bytes, next() looks approximately like this…

@inline(__always) @inlinable mutating func next() async -> UInt8 {
    if bufferRange.isEmpty { await refillBuffer() /* does suspend */ }
    return buffer[bufferRange.popFirst()] /* doesn't suspend */
}

Previously:

Boox Nova Air Review

Jason Snell:

What if someone built a tablet that could run a wider selection of apps but still had the crisp, clear look of an E Ink screen?

In fact, a few companies have been trying to marry E Ink with Android for a while now. Recently I got a chance to spend a lot of time with the Boox Nova Air, a $389 Android tablet with an E Ink display, just as I was also spending time with Apple’s $499 iPad mini.

[…]

Once I was able to get everything set up, was I able to use the Boox Nova Air as a reader for my newspapers, RSS, newsletters, and other content apps, as well as for ebooks via the Kindle and Kobo apps? Yes, I was. But with the exception of the book-reading apps—which were built for a page-at-a-time reading experience that’s perfect for E Ink—what I found was that using apps intended for standard screens was always awkward.

Previously:

Redesigning iOS Alarm and Timer Notifications

Matt Birchler:

What’s always confused me is that the timer makes “I’m done with this” the primary action, while the alarm makes “I need more time” the primary action. Why is this? Even after years with this UI, I still get it wrong sometimes because I have to do some thinking on “is this an alarm or a timer?” which isn’t terribly hard, but it’s harder than normal when you’re either tired and have a phone blaring annoying sounds at you.

[…]

No matter what the reason, I think there are a few main problems with the current UI, even if there is a logical reason to have their order flipped.

  1. The order of options is flipped between timers and alarms.
  2. The colors in the UI don’t seem to indicate anything. Orange is destructive? The opposite? 🤷‍♂️
  3. The buttons are smaller than they need to be.

And there’s a huge amount of empty space, yet no icons.

Previously:

TextExpander 7

Diana Prodan (release notes):

15 years ago, the small team of developers at Smile acquired the core product we now know and love called TextExpander. In those 15 years, we’ve been through many iterations and changes to the product, and our small team has expanded to almost 40 team members.

[…]

Enhanced Snippet Suggestions make it even easier to notice and create Snippets from frequently-typed words and phrases.

[…]

The app now shows you how to resolve conflicts with your Snippet abbreviations in a clear, easier-to-use interface.

[…]

You can now view search results by group, and adjust how your search results are sorted and presented to quickly find what you need.

Pricing is unchanged.

Previously: