惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
爱范儿
爱范儿
WordPress大学
WordPress大学
V
V2EX
宝玉的分享
宝玉的分享
小众软件
小众软件
B
Blog
博客园 - 叶小钗
U
Unit 42
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
H
Help Net Security
P
Proofpoint News Feed
D
Docker
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
月光博客
月光博客

Ben Frain

Well done AI, that’s the end of the honest boxes The Beginnings, by Rudyard Kipling So, you want a React modal that uses the <dialog> element and transitions in AND out? Scroll indicators on tables with background colours using animation-timeline Review: SoundPEATS Clip1 Open ear clip-on headphones VS Code – highlight just the active indent guide Review: MoErgo Go60, a split ergonomic and fully programmable keyboard Review: Kinesis mWave mechanical ergonomic and programmable keyboard iOS26 Safari theme-color/tab-tinting with fixed position elements is a mess New Book: Responsive Web Design with HTML5 and CSS, 5th Edition Use @supports with a proxy feature/value for features you can’t test for (@starting-style) First adventures in View Transitions Review: Benq Screenbar Pro and Halo lightbars. The kit you never knew you needed! Center items in a container, and make then left aligned when they overflow A single element CSS donut timer/countdown timer, that can sit on any background Review: Open Ear Headphones – Bose Open Ultra v Huawei FreeClip In search of the perfect autocomplete for CSS Managing multiple versions of node, without NVM or additional tools Review: Keychron Q14 Max Alice 96 Key mechanical keyboard NEW VIDEO COURSE: Responsive Web Design with HTML5 and CSS Is CSS Grid really slower than Flexbox? Review: Advantage360 Pro Signature Edition 2024 mechanical ergonomic keyboard More Keys or Fewer Keys for mechanical keyboards Yes! You can use position: sticky and overflow together Neovim – how to do project-wide find and replace? Review: Keyboardio Model 100, split, wooden, mechanical keyboard How to create rounded gradient borders with any background in CSS How to get equal size icons in the cmp completion menu of Neovim with Kitty terminal Review: Dygma Defy, split, mechanical, programmable ergonomic keyboard What’s the best way to reset WAAPI chained animations?
Struggling to learn SwiftUI
Ben Frain · 2024-02-15 · via Ben Frain

For the past ten days or so, I have been trying to gain some basic competency with SwiftUI.

I have found it hard. Very hard. But I finally feel there is a sliver of light in my comprehension. Just enough to give me the confidence to write this here, thinking there may be more posts on SwiftUI to come.

Why so hard

My aims for SwiftUI are the same as they are with web technologies; principally, to make high-fidelity prototypes to test out designs. SwiftUI will just give me another medium to work with, and hopefully negate the need to make prototypes for native app features in a different medium; web tech.

And so I set out watching and reading and trying to get my head around SwiftUI.

At the outset, I was very encouraged. Conceptually, SwiftUI, surely by no mistake, is very reminiscent of web frameworks like lit.dev and React. Something I am comfortable with.

Components are essentially ‘Views’ in Swift parlance, and in SwiftUI, you pass state, or reference state from some global location, and the declarative View that you have written updates to the new state.

So, with such familiar conceptual underpinnings, I don’t know why I have found it so hard to start to use SwiftUI.

“…I’m too old for this shit”

However, a few days in, the thought crossed my mind that maybe, like the fact my body can no longer manage a full game of football, my mind simply lacks the elasticity to learn new things?

I was watching and watching, reading and reading, trying to make things, just simple things, any thing, in Xcode and it just was not happening.

A kind of fear gripped me.

Writing the correct syntax seemed like simply memorizing some bizarre magic incantation, with no basis in logic. Add to that, that, unlike on the web, where techniques from the past live for all eternity, in SwiftUI, at Apple’s convenience, they are simply removed. So something that reasonably worked in 2021, does absolutely not work in 2024. Or gives you so much warning in the editor, you couldn’t in good faith leave it in.

For example, good ol’ ChatGPT would keep telling me with insistence I should use NavigationView which is simply not a thing in later iOS versions.

Frustration heaped onto frustration, as things like reading in a JSON file to iterate over it in the UI remained unfathomable to me.

I spoke to colleagues, they suggested treating it like first experiences with the web, and just get images in and see if you could navigate between them as faux ‘pages’ of the app rather than make pages with ‘real’ content.

I subsequently scaled back my already humble ambitions further.

More days of fruitless labour followed, every step forward presented two steps back as some new blocker revealed itself. I started to write up each new issue and ask the question on the ‘Hacking with Swift’ forums (I have pretty much given up on Stack Overflow as it seems near impossible to ask any question that isn’t immediately shut down as a ‘duplicate’).

I was going to bed each evening with my head ‘humming’, and waking up with a sense of dread.

I had looked at SwiftUI a couple of years back and been equally frustrated and ultimately retreated back to the warm embrace of web technologies. However, this time, I didn’t feel that retreating was an option. But I was 100% not having a fun time.

Something changed

Then yesterday, something altered, subtle but noticeable. I had started to get an intuition for what would work and what wouldn’t. To some degree perhaps, a sense of what SwiftUI was expecting with the simplest of interactions.

Let me be clear. These are the very beginning of steps along a journey. Absolute basic stuff. But I at least feel I am starting to occasionally shuffle my progress forward, in the belief I will one day walk.

At the outset there wasn’t a hole in my knowledge, there was NO knowledge. Now, I at least feel there is a merely a gaping chasm to cross.