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!
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. ... "
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:
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)
}
}
WWDC'23 videos are now on YouTube
All videos from WWDC'23 are now available on YouTube, nicely grouped into themed playlists 🎉
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:
✌️
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 ❤️
Member discussion