4 min read

Issue #67

Hi there, welcome to the 67th issue of iOS Code Review! I hope the spring is treating you well ☀️ Let's learn something new!

Are you motivated by the craft of writing Swift? Want to improve your productivity and the quality of your results? Want to hang out with other awesome developers with the same mindset?

Swift Craft is a brand new conference for passionate developers working on Apple platforms. Set in a UK seaside town with stunning views across the English Channel, with an incredible line up of some of the community' top speakers, delivering dozens of sessions on the latest Swift features and writing even better code - this is the inaugral event you won't want to miss!

Find out more and check out the full schedule

Handling family shared in-app subscriptions

Apple's sample code for managing in-app purchases has a line of code that is seemingly innocent, but in fact makes the example not support Family Sharing for in-app subscriptions:

subscriptionGroupStatus = try? await subscriptions.first?.subscription?.status.first?.state

Here status is an array and any the elements can be in a subscribed status:
" ... With Family Sharing, the people who are using the subscription act independently: one may subscribe for a year and then cancel. Then another could subscribe at a later date for only a month. You have to check all of the subscriptions, not just the first one. ... "

App Store Subscriptions and Family Sharing • furbo.org
A toot by my friend Casey brought back some frustrating memories about expired subscriptions that haven’t expired (yes, really). This blog post will hopefully help you avoid having these same recollections. It all begins when a customer contacts you with a screenshot that looks something like this: Your code and the App Store don’t agree […]

Date decoding strategies in Swift, with examples

We don't usually use the default .deferredToDate decodingStrategy of the JSONDecoder/JSONEncoder, and here's a nice article walking through the different options and when you want to use them:

Date decoding strategies in Swift [with Examples]
The JSONDecoder class uses several decoding strategies to decode dates encoded using different formats in JSON data.

Trigger value pattern in SwiftUI

" The recent version of the SwiftUI framework introduces a trigger value pattern across its APIs. Trigger value allows us to attach a view modifier that runs its action whenever the trigger value changes. You can find this pattern while using sensory feedback or launching keyframe animation in SwiftUI. This week, we will learn how to build custom view modifiers using trigger value pattern. "

Here's an example of a SwiftUI API using this pattern:

struct TriggerValueExample: View {
    let messages: [String]
    
    var body: some View {
        List(messages, id: \.self) { message in
            Text(verbatim: message)
        }
        .sensoryFeedback(.impact, trigger: messages)
    }
}
Trigger value pattern in SwiftUI
The recent version of the SwiftUI framework introduces a trigger value pattern across its APIs. Trigger value allows us to attach a view modifier that runs its action whenever the trigger value changes. You can find this pattern while using sensory feedback or launching keyframe animation in SwiftUI. This week, we will learn how to build custom view modifiers using trigger value pattern.

WWDC'23 videos are now on YouTube

All videos from WWDC'23 are now available on YouTube, nicely grouped into themed playlists 🎉

Apple Developer
Hello and welcome to the official Apple Developer YouTube channel.

WWDC'24 Special Event application

Tonight is the deadline for requesting to participate in the in-person event at this year's WWDC. If that's your type of thing, you can apply here:

WWDC24 Apple Park Special Event
We’re hosting a special all-day experience at Apple Park on June 10 to kick off WWDC24.

✌️
Alright, that's it for today! Let's spread the good code vibes ✨🧘🌈☀️
I'm curious if you found any of the tips particularly interesting - let me know by replying to this email!

Thank you to Swift Craft conference for sponsoring this issue ❤️