Paul Hudson

@twostraws
11.8K Followers
120 Following
2.9K Posts
I write Swift and write about Swift, but most people prefer my dogs.
Pronounshe/him
Websitehackingwithswift.com
GitHubgithub.com/twostraws
For HWS+ subscribers: Every new file gets the same default header comment, but Xcode has a flexible customisation system with built-in macros for filenames, project names, and more. https://www.hackingwithswift.com/plus/learn-something-new/personalizing-your-xcode-header
Personalizing your Xcode header – Hacking with Swift+

We make new files in Xcode all the time, but if you spend just a few minutes you can customize the comments that are automatically placed at the start to make them suit you much better.

Hacking with Swift

RE: https://mastodon.macstories.net/@macstories/116799677346665537

I know a lot of people are jaded about Prime Day, but having spent a year studying Amazon's pricing, there are some truly good deals to be had if you look hard enough, which I did.

I compiled a list of the best deals on a load of gadgets, most of which I've used and reviewed myself.

Renaming a SwiftData property without @Attribute(originalName:) will silently discard your users' data. One small macro saves a lot of heartache. 😬 https://www.hackingwithswift.com/quick-start/swiftdata/how-to-rename-properties-without-losing-data
How to rename properties without losing data - a free SwiftData by Example tutorial

Learn Swift coding for iOS with these free tutorials

Hacking with Swift
Sometimes 64 bits just isn't enough, which is why Swift also support Int128 and UInt128. The evolution proposal itself admits the API is "uninteresting" - but those are very, very big numbers. https://www.hackingwithswift.com/swift/6.0/int128
128-bit Integer Types – available from Swift 6.0

128-bit Integer Types example code from Swift 6.0

Hacking with Swift
Sunday Build with HWS+: An original word game where players fill a 5x5 grid to spell five words across and five words down simultaneously, with drag and drop plus tile locking. #SundayBuild https://www.hackingwithswift.com/plus/live-streams/5x5
5x5 – Hacking with Swift+

There are lots of word games, but very few original word games. Let’s build one today, with delightfully simple drag and drop mechanics plus locks in place to avoid annoying players as they progress.

Hacking with Swift
The next Hacking with Swift+ live stream starts in two hours! We're building another complete app from scratch, ready to ship to the App Store πŸ™‚ https://www.hackingwithswift.com/plus
Hacking with Swift+

Subscribe to Hacking with Swift+ and get advanced Swift tutorials to help take your career to the next level.

Hacking with Swift
containerRelativeFrame() lets you size views as fractions of their container: split the space into parts, assign a span, and let SwiftUI handle the maths. https://www.hackingwithswift.com/quick-start/swiftui/how-to-adjust-the-size-of-a-view-relative-to-its-container
How to adjust the size of a view relative to its container - a free SwiftUI by Example tutorial

Learn Swift coding for iOS with these free tutorials

Hacking with Swift

RE: https://mastodon.social/@twostraws/116687055888030496

There's still time to save 50% on my books and bundles – nail coding interviews with Swift Interview Challenges, dive deep into how SwiftUI works behind the scenes with Pro SwiftUI, or check out my Everything Pack for the biggest discount of all!

You can access .lines directly on a URL to stream remote text data line by line. No URLSession boilerplate required, and it works beautifully for CSV parsing, real-time data, and simple text fetching. https://www.hackingwithswift.com/articles/241/how-to-fetch-remote-data-the-easy-way-with-url-lines
My favorite new Swift API from iOS 15

AsyncSequence and effectful read-only properties combine to make something beautiful.

Hacking with Swift
For HWS+ subscribers: Ever wonder why you can write let names: Set = ["a", "b"] even though that looks like an array? ExpressibleByArrayLiteral is the protocol behind it, and you can use it in your own types too. 🧩 https://www.hackingwithswift.com/plus/inside-swift/expressible-by-array-literal
Expressible by array literal – Hacking with Swift+

Although Swift is a very strict language, it also sprinkles a great deal of syntactic sugar around to make our lives easier. Let's explore a part of that here: types that are expressible as array literals…

Hacking with Swift