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)
https://gist.github.com/phillipcaudell/8509aba4f3fc064b3d7bfbb1fefbe9a9
back in my day you could swizzle the whole runtime using a fork whilst hot swapping a UIViewController from space and no one ever got hurt
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!
https://gist.github.com/phillipcaudell/99d1fe52873d0c5115bc281272003784
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.
https://gist.github.com/phillipcaudell/df04ebf01e9579a308e3534ac829a540
Edit: Perhaps this is just a quirk of Xcode Previews: https://mastodon.notsobig.co/@phill/111051676536041177
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
https://gist.github.com/phillipcaudell/f6258c1fbac69a9fb2cd030fadd087de
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: https://gist.github.com/phillipcaudell/290eab2c42c4cc27cfdc0c595b40654d
Here’s one weird #SwiftUI 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: https://gist.github.com/phillipcaudell/ecb32dc5a3915931d225a6cb8a67ac34
Introducing Obscura 4
A camera app built for pros and designed for everyone.
Obscura 4 has been redesigned and rebuilt to be faster, nicer, and easier to use than ever before.
Download it now: https://apps.apple.com/app/apple-store/id1579306989?pt=96658924&ct=Mastodon&mt=8
Some interesting differences about List on Mac:
1️⃣ Swipe Actions are eagerly loaded. On iOS these are lazily loaded.
2️⃣ List immediately buffers ~300 cell bodies. On iOS it's about 10.
3️⃣ Cells don't respond to isFocussed, whereas on iOS they do.
4️⃣ “Select All” will immediately buffer all cells and lock up your app.
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?!)
https://gist.github.com/phillipcaudell/4cc223bec9a18970aed489d06580a56d
This doesn't seem that intuitive at first, but if you think about it, how would SwiftUI anticipate what action will be performed on your model?
In iOS 17 the animation has been improved considerably if you don't explicitly set the role, but for best results you still need to set it.
🏳️🌈 Founder / Maker
Building that new email app.
Swift and rollercoasters are my thing.
Recovering VC.