SwiftUI's new Preview macro & SwiftData can be a match made in heaven, but only if you know how to use it...
In this video, we'll be looking at just that:
👀 Building A Container For Previews
🤲Prefilling Previews
⚡️Building Our Own Previews Component
I’m a data person, not a UI person.
I’m simplifying here, but…
I love #SwiftUI and do not love #UIKit.
I do not love #SwiftData and do love #GRDB.
I think it’s because SwiftUI enables me to do stuff I am bobbins at, whereas SwiftData makes me cry because it’s not just raw SQL.
Again, simplifying. An observation (I flippin’ love the new Observable stuff!) is all.
#swiftui #UIKit #swiftdata #grdb
#GoodBatch now autosaves constantly in background after switching to #SwiftData. Win-win-win:
• No data loss if beta crashes
• Less work, no explicit save
• No save button, simpler UI
• Background thread doesn’t make typing lag
@helge Thanks for the heads up! I follow your #SwiftData adventures with great interest, even though I'm still not playing with it at all. Currently too busy trying to figure out a good Swift version of the SQLite JSON functions in #GRDB in https://github.com/groue/GRDB.swift/pull/1423 (surprisingly less easy that one could expect, due to sensitive SQLite subtleties 🤯)
I did have to add a wrapper to my swiftUI previews so that they played nice with the #swiftdata models though!
I know writing a custom NSMergePolicy is rarely needed, but if you do find you need to write one, Apple’s lack of documentation makes it nearly impossible to diagnose if you do it wrong. I wrote the missing documentation so you don’t have to flounder around like I did.
TLDR: Be sure to call super, or else it all falls apart. Not intuitive, but the base merge policy respects your changes.
https://quigs.blog/how-to-write-a-custom-coredata-nsmergepolicy/
#CoreData #SwiftData #iOS #Apple #Developer #iOSDev #Documentation #Blog #HowTo
#coredata #swiftdata #iOS #apple #developer #iosdev #documentation #blog #howto
Is this #SwiftData documentation new?
It seems we finally have some guidance on how to use the same View to create & edit an object with the option to discard: by using state variables for each editable value & not by binding directly to a model object.
https://developer.apple.com/documentation/swiftdata/adding-and-editing-persistent-data-in-your-app
🚀 Big News! My course "Design to #SwiftUI Presents... Building an Apple Watch Store App in iOS 17" launches Sept 18! 🗓️ Be among the first to master #SwiftData & iOS 17 features. 📱 Pre-order NOW 4 a reduced rate! 🎉 Don't miss this deal! #iOSDevelopment
#swiftui #swiftdata #iosdevelopment
I'm wanting to keep track of the user's most recent navigation status.
Currently I have that tracked in an @Observable class, but feel like it would make sense to move this to my #SwiftData store, for persistence?
BUT, I want the user to have saved state per device, ie it should be a "local" persisted value.
Should I just use @AppStorage? Is there a way to have values tracker per device (like .unique/.transient, etc.)?
Should it just be a secondary store?
If you've ever wondered, how to prefill SwiftData with items that have a relationship, then this is the video for you 🤝
We'll cover:
💕 Preloading items with relationships
🏞️ Preloading images
👀 Using Codable with SwiftData
SwiftDataめっちゃええやん。
https://qiita.com/Ri__/items/0c46c432b2e873ceeb04?utm_campaign=popular_items&utm_medium=feed&utm_source=popular_items
#qiita #iOS #Swift #iOS17 #SwiftData
#qiita #ios #swift #ios17 #swiftdata
@thillsman @joshdholtz yes, but in my case the last one was such an unmitigated #swiftdata disaster I'm starting from scratch. Someday there will be real docs. Or everyone will watch this course I'm writing.
The UI of my #Contacts app to stay connected with people long-term is complete, including #search! 💪
Last 2 steps before kicking off the #Beta:
– Persistence with #SwiftData
– Server & API with #Vapor
Let’s see how nice SwiftData really is!
#WIP #NAPDev #SwiftUI #BuildInPublic
#contacts #search #beta #swiftdata #vapor #wip #napdev #swiftui #BuildInPublic
Join us tomorrow for Swift Remote Coffee! ☕
Swift Remote Studio’s weekly virtual coffee meetup for Swift/iOS/Mac developers that takes place on Zoom every Wednesday at 9am PT.
We usually end up chatting about #Xcode #Xcode15 #SwiftData #SwiftUI #visionOS #VisionPro, etc.
1. Sign up at http://swiftremotestudio.com
2. Join the Slack workspace via the invite email
3. Go to the "coffee" channel in Slack for the Zoom URL
See you there! 😃
#xcode #xcode15 #swiftdata #swiftui #visionos #visionpro #iosdev #worktogetherswiftly #swiftremotestudio
So many reasons to target iOS 17+ & drop support for older versions:
- MapKit for #SwiftUI (annotations & overlays)
- #CoreLocation now supports live updates using Swift concurrency’s async/await capability
- #SwiftData (no, just a joke, I'll stick to my #CoreData stack for now)
#swiftui #corelocation #swiftdata #coredata
I figured out more about this ‘bug’. It wasn’t what I thought it was. You cannot use the word `description` as a variable in a #SwiftData schema anywhere. it also hepls when debugging to completely reset your device.
ANNNNNNNDDDD...... :scream: So, I spent a good part of the day fixing one problem, only to find the problem is part of an even bigger problem. Reading from a class or struct that adopts Codable causes a fatal error in #SwiftData. I was loading a JSON file with my menu data, and apparently, 1) Codable does not like the enum dodge I was using above to read JSON data, so I changed it to simple strings so it would read correctly. 2) Then I get this lovely crash
SwiftData/SchemaProperty.swift:369: Fatal error: Unexpected type for CompositeAttribute: MenuItem
I have a way around Codable for this project, though it will take some work, but that is a very bad thing.
Now I remember why I avoid backend or any Model development and Stick to UI. #SwiftData
TIL: The simulator is not reliable when testing #SwiftData with #CloudKit.
You need at least two physical devices, unless you want to spend hours on trying to figure out why your your data doesn't sync – when it actually is syncing as expected.
I’m a tad confused.
• Do we need to explicitly set defaults for *every* variable in our @Models?
I have some structs that I *don’t* want to sync, yet, as some of the stored values don't conform to `Codable`.
• Am I right in assuming that @Transient will "suppress" those warnings?
Lastly, it appears we *should* be marking things as Optional, but then I have nth code refs to change. Is there a better way to handle these?