Show newer

Why is deinit not called here?

If a StateObject's lifetime is that of the containing view, popping from the stack should deallocate it. But it doesn't.

Weirdly removing the List's selection binding results in a dealloc as expected.

Is this a memory leak with List or am I missing something? (iOS 17/latest Xcode)

gist.github.com/phillipcaudell

“Your engineers were so preoccupied with type-safety that they didn't stop to think if they should”

– Ian Malcolm, 1993

I need an ”AnyCodable" type for serialising some generic stuff.

Is something like this the best approach now that we have existentials on protocols?

AnyThoughts appreciated!

gist.github.com/phillipcaudell

I'm a little embarrassed to admit, but I had been blissfully unaware that View extensions are type erasing.

That means if you have an extension for using your ViewModifier in a more ergonomic way, it'll be erased to AnyView unless you explicitly mark it as @inlinable.

gist.github.com/phillipcaudell

Edit: Perhaps this is just a quirk of Xcode Previews: mastodon.notsobig.co/@phill/11

NavigationStack loses its navigation bar on iPad when returning from the background, making it impossible to go back or do anything. iOS 16 and 17.

FB13120953

gist.github.com/phillipcaudell

Something that tripped me up recently was not understanding how .onAppear { } behaves on iPad.

It gets called multiple times, even though the view is not visible.

Why? Logging reveals the size class is also changing, so presumably iOS is taking snapshots for the app switcher.

If like me you rely onAppear to denote a user has seen something (say, Mark as Read), you'll need to check the scenePhase first.

Here's a gist: gist.github.com/phillipcaudell

Here’s one weird trick Apple DON'T want you to know:

If you present a confirmation dialogue from a swipeAction or contextMenu nothing will happen as the view is removed before the dialogue is presented. Annoying, but it makes sense.

Instead, delegate the confirmation to the environment. Now the Button isn't responsible for the presentation and you're left with a nice clean call site.

Here's my implementation with an example: gist.github.com/phillipcaudell

i’m pleased to report you can make the iPhone simulator gay now

Man, NavigationSplitView is *still* broken in iOS 17 beta 7.

I reported back in May (FB12178616) that when in compact mode transitions become sporadic and stop working. This code is verbatim from Apple’s docs and it doesn't work.

This broke back in iOS 16.2. It seems nuts to me something so significant can stay broken for this long (and on a relatively new API?!)

gist.github.com/phillipcaudell

I recently got downvoted into oblivion for explaining why someone's List animation was glitching, perhaps because the solution is so simple it seems stupid.

On the left is swipeAction with a Button. On the right is the exact same Button, but now the animation is smooth.

The difference? I set the Button's role to destructive. SwiftUI uses the role to infer what animation to use. gist.github.com/phillipcaudell

live scenes of me keeping all size classes and platforms working from a single target

As of beta 6 it seems to be reporting the wrong value if more than one row is selected on iPad.

I've filed a feedback for any Apple folk who see this 👉 FB13014204

Show thread

Happy to see iOS 17 now gives our views a way to respond to the List selection style.

By reading the backgroundProminence value in the environment our custom controls, say an unread indicator, can adjust their tint as not to be occluded by the background: gist.github.com/phillipcaudell

Show older
The Not So Big Company

The home of The Not So Big Company on Mastodon.