👋 Our "Launch Your First App" program will help you build up your iOS skills to publish your very own feature rich app even if you’re a beginner starting from scratch. cwc.to/youtubeoffer
I find it kinda funny I was asking "why the underscore on the parameter name?" as you kinda just glazed over it in the delete function and I HAD TO KNOW so I went and looked it up. Then a bit later you explain it for the update function.. I SHOULD HAVE TRUSTED YOU GOOD SIR. SwiftData is pretty awesome though. I'm...struggling to get a good grasp on Swift. I've been doing C and C# for much of my life and something about Swift just throws me off. But your channel has at least put me in the right path.
Hey I just started watching your videos and I was intrested your collection of keyboards that are always prominent in your videos. Would be cool to see a video talking about your keyboards or a setup tour.
Thank you Chris that is good, I'm going to be undertaking in my second semester as part of my masters in IT the unit in iPhone software engineering. I hope they are up-to-date as you are!
Hey Chris, I have a question for you. After watching wwdc 2024, i see that swift data now supports more operations, like history tracking and custom model configuration implementation. Would you say that SwiftData is now ready to be used? Also, did they resolve a bug, when you decorated your model with @Attribute(unique) that the app crashed ?
I have a core data app that I’ll be changing to swift data after seeing this. Question: in my app now, I can click a button in one view that will add item to core, then when I go to view that has the list it will be there. I’m assuming this will be easy to do in swift data also? Not sure how I’ll do that though.
Hello @maryannadelman4438! To be honest I'm not sure how to answer your question, maybe our community members can help. You can share this to our community forum @ [codecrew.codewithchris.com/] --Joash
Do you still need Identifiable protocol? Really good video thank you. From another tutorial ‘SwiftData automatically handles the identification aspect of the model, eliminating the need for explicitly defining an id property or conforming to the Identifiable protocol.’
I'd still add a UUID (not a String). That way, it allows you to separate out distinct models instances, even if they happen to share the same data. It would be better for your own sanity, and debugging.
I've read up quite a few information since, I feel like with SwiftData MVVM seems less relevant and it might become more complicated if we strictly want to implement MVVM.
Love Your videos!! I have started a project in SwiftData, but I can not get the @Query to filter on date?? I've checked all the forums, and many people seem to be struggling, but no real answers that work for me. Any advice on filtering on date in SwiftData??
wow! so much better than the coreData workflow. So will swift data ever be compatible with older iOS versions or will it only ever be compatible for iOS17 and up? I can't wait until this becomes the standard and we can shove coreData into the abyss. but if it's only ever going to be compatible for iOS17 and above then it's going to take some years right?
also, Chris - your teaching style is world class. You have the advantage of having a very easy voice to listen to. I really do hope you make a "100 Days of Chris UI" or something in the future
Is there some kind of visual view integrated to Xcode to see the current database layout, entities, relations, and data and so on? Like pgAdmin for Postgres for example?
Brand new to Mac development. Never used coredata. Where can I find the rest of the tutorial that explains things like… how .onDelete creates these magical indexies , and why they swipe view shows up without any code, showing anything about swiping etc. thanks!
I made a video on this, but it's not specific to SwiftUI, but how to write good Swift code in general ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-4hVyozTOSTo.htmlsi=K8ORdCwzcDNpFPB9
Why is everyone stuck with todo program? There are like millions of example online for todo program. Why not do user login and register and delete user using swiftdata. But thank you for this amazing tutorial.
I am getting an error at part 8:07 "Missing argument for parameter 'id' in call" I'm using Xcode 15.0 and iOS 17. Can you explain what I am missing as I am new to swift and swiftdata.
I was able to figure out the issue with the addItem module had to use *let item = DataItem(id: UUID().uuidString, name: "Test Item")* after that everything else was smooth sailing. Great tutorial on SwiftData. Subscribed and can't wait to watch more videos. Thanks
In more complex applications we usually use different design patterns like the repository pattern and try to move away the functions from the view itself. How would you implement a repository pattern etc. with the SwiftData? :)
can someone help me please .. i have a SWIFTUI application with a flow as follows: A(landscape orientation)->B(landscape)-C(portrait)->D(portrait). also when I navigate back from C to B it should turn back to landscape as B is in landscape. (I am using NavigationLink in my application to navigate)How do I achieve the portrait lock in swiftUI. i tried the .onAppear{} and .onDisappear{} method.. (firstly it is no longer available on ios 16 and secondly it gives a choppy animation where the view does not expand fully to take the new rotated screen size; there is white space after it rotates)
Hello, @VladislavVaz! Unfortunately we can't debug it for you in the comment section here but you can try joining and posting in our community: cwc.to/codecrew --Joash
Should we still use codable structs to decode JSON API responses or should we use the new codable @Model class to decode API responses? Which is better?
You can actually do both, but if you add the Codable conformance to your SwiftData model, you'll have to manually write the Decodable and Encodable conformances yourself, as derived conformance simply doesn't work out the box. @Model is a Swift Macro, and it adds boilerplate code that does not conform to Codable (that's why derived conformance doesn't work). Donny Wals has written a great article about it, you may want to read about it here: www.donnywals.com/making-your-swiftdata-models-codable/ Have a good day! - Iñaki
@CodeWithChris Hey Chris, as soon as i typ in: "@Model", there comes a red message saying: "@Model requires an initializer be provided for 'DataItem". Please help. What did I do wrong?
Hello, Unfortunately, we can't debug it for you in the comment section here but you can try joining and posting in our community: cwc.to/codecrew --Joash
I get a Preview Crashed error when I try to add a record to the model. Does anyone know why that would happen? I'm pretty sure the code looks the same as Chris's code.
Does it show any error in the console log? If it does, you may wanna post about it in our developer community forum: cwc.to/codecrew Someone might be able to help see what's wrong with your code or be able to determine what caused the issue. - Iñaki
No, SwiftData is not an embedded database, it's an object graph and persistence framework, more like an ORM. It uses SQLite as one of its persistent store. You can sync data from SwiftData and MongoDB Atlas but it requires extra and redundant work, I wouldn't recommend it. SwiftData comes with built-in support for iCloud syncing. If you need to sync data from your app to Mongo Atlas DB, I recommend using Mongo Realm instead of SwiftData (www.mongodb.com/docs/atlas/device-sdks/sdk/swift/). - Iñaki
Hello, @DefeatOG! Unfortunately we can't debug it for you in the comment section here but you can try joining and posting in our community: cwc.to/codecrew --Joash
Hey! When I query my database and try to insert the variables like name, it throws up an error saying "Value of type '[my class]' has no member 'name'". Is there something simple I'm missing?
Hi! Sorry you're running into that! Have you checked if there is a `name` property in your data model class? You can declare it like how Chris did it on this timestamp: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-krRkm8w22A8.html Hope that helps! - Iñaki
Darn ... too bad this is unusable while working with MVVM, I tried today to somehow bend it to my will ... guess what ... went to core data after ready long struggle.
"To provide automatic iCloud sync, SwiftData requires the CloudKit entitlement and an iCloud container. For more information, see Configuring iCloud services." For more information, you can check out: developer.apple.com/documentation/swiftdata Thanks for watching! - Iñaki
Hi, in the video Chris ran the app in the Simulator instead of using the SwiftUI preview. There is an additional code setup required to make the SwiftUI preview work with SwiftData, but it doesn't simulate any persistence functionality that you might expect. To run the app similar to the video, make sure to select a Simulator as your destination (on the top middle part of Xcode), then press Cmd + R. Xcode should build the project and launch the app in the iOS Simulator you chose. Hope that helps! - Iñaki
Hi @JustYe322, Yes! Xcode run on any mac. You can also check this link to see the minimum system requirements to be sure that your machine can working on the latest version available. developer.apple.com/support/xcode/ Hope this help. --Joash
Nice work on separating behavior from view. Too few examples take the care to demonstrate clean code. You, sir, have saved many headaches by teaching good practices
Hello @babida9113! Unfortunately we can't debug it for you in the comment section here but you can try joining and posting in our community: cwc.to/codecrew
Hello @Kyriacos-ue5kt, Indeed, you can utilize the new SwiftData API across all Apple development environments. It's not exclusively limited to iOS. --Joash
Technically you wouldn't use it "in Vapor" but with Vapor. Vapor is for making an API (completely separate from your iOS app), and SwiftData is for storing data locally on the device, as a replacement for CoreData. You'll have to write your own syncing engine to keep the local and cloud data in sync. This is possible, but with SwiftData being so new, it may be tricky. I have never done this, so I can't really say if it's scalable
Hey Chris, I have a question for you. After watching wwdc 2024, i see that swift data now supports more operations, like history tracking and custom model configuration implementation. Would you say that SwiftData is now ready to be used? Also, did they resolve a bug, when you decorated your model with @Attribute(unique) that the app crashed ?
10:35 I think that this delete method is simpler and fancier, but I think your method is more trusty .swipeActions(edge: .trailing) { Button("Delete", systemImage: "trash", role: .destructive) { context.delete(item) } }
Hello,@napoleontsar! You may want to check this video to learn more about NavigationStack. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-7dnTHrLyFLc.html&ab_channel=CodeWithChris --Joash