Ok ok, I know Super Saturday Sharefest is not a thing, but it’s too late for Follower Friday, alright? I want to give a big shout-out to Matt Massicotte of ChimeHQ for dropping another awesome Swift open source package that makes using XPC Swift-ier. I’m really grateful for all the amazing work Matt has been doing and for sharing it with the community.
In my opinion, the new section headers of NSMenu don’t have enough top margin. In the WWDC 2023 example, there are no “descenders” in the menu title typo of e.g. “Section 2”. (Descenders are e.g. the lower-case g or p going below the baseline.)
My recent posts were about SwiftUI quirks and annoyances, so I want to share a short success story for a change: You can @import Swift Packages in Objective-C code just fine. (At least if they are Objective-C compatible.) I updated my WordCounter app to rely less on Carthage and use Swift packages where possible instead.
With Xcode 14.3.1 on macOS 13 (Ventura), I found that you cannot put SwiftUI.Menus inside Lists without breaking the key event loop – iff you also set the menu button’s .buttonStyle(.plain)! Once that button style is used, menu item interactions will make the app
I wanted to know how a SwiftUITextField gets to know its onSubmit handler to wire my own NSViewRepresentable to it (would be the same for a UIViewRepresentable). There’s no key for that block in the EnvironmentValues structure that you get from the “context”, though.
while loops with extra conditions (case let matching),
if-case statements.
(Missing, for completion: catch ... where in try-catch blocks.)
I believe there’s tremendous value in summaries like these to learn the Swift programming language and its syntax: these short summaries show a slice of different aspects of the language in close proximity.
The Swift language book tells you all about the structural programming features one after another in the Control Flow chapter: if, for, while, etc.
It also has a section on where, but that’s limited to the switch conditional statement.
The section on for loops doesn’t mention where clauses at all! You need to go to the Language Reference part of the book, where the formal grammar is explained, to read that a where-clause? is allowed.
for-in-statement → forcase? pattern in expression where-clause? code-block
So a post like Natalia’s reminds us about the similarity of different aspects of the Swift programming language.
It’s zooming in on where-clauses, and so the reader gets to know a different “view” into the syntax as a whole that is different from the book’s presentation.
This should be very valuable to get from beginner-level understanding of “I can do things in Swift” to a deeper understanding of recognizing similarities across different aspects of the programming language.
These should, in my opinion, be included in the language’s handbook to help with “deep learning”. Until then, I’m glad we have posts like Natalia’s!