SwiftData For Beginners: How To Build A To-Do List App In SwiftUI | #1

  Рет қаралды 24,847

tundsdev

tundsdev

Күн бұрын

Пікірлер: 174
@tundsdev
@tundsdev Жыл бұрын
🚨Xcode Update🚨 At 21:08 starting from Xcode 15 Beta 5, when sorting items you now need to include the root in the keypath too, so update the sort parameter to look like this. @Query(sort: \ToDoItem.timestamp) private var items: [ToDoItem] If you're having issues wtih the SwiftUI Previews I'd recommend watching my video in this course that shows you how to handle working with SwiftUI Previews & SwiftData down below! kzbin.info/www/bejne/oHSmZKyrmJqAi6s
@tundsdev
@tundsdev Жыл бұрын
Also when working with filters you need to specify the type too below is an example @Query( filter: #Predicate { $0.isCompleted == false } ) private var items: [ToDoItem] A combination of the two would look like this @Query( filter: #Predicate {$0.isCompleted == false}, sort: \ToDoItem.timestamp ) private var items: [ToDoItem]
@keegan8176
@keegan8176 Жыл бұрын
Thank you !! 😅spent a while stuck on this and couldve just opened the comments @@tundsdev 🤦‍♂
@dibjr
@dibjr 10 ай бұрын
In the release Version 15.0.1 (15A507) the root is no longer required.
@nileshjdarji
@nileshjdarji 2 ай бұрын
It's great that you are pasting code to save time but it would be nice if you quickly go over the code that you pasted so we don't have to pause the video and read the code. Because sometimes there is more code to fit in the screen and we cannot see everything at one time. Just a suggestion. I am enjoying this series.👍
@ShawnChristopher10101
@ShawnChristopher10101 Жыл бұрын
Thanks for the video. Getting into Swift now from a C#/React/Angular and this makes sense. Going to check out your other videos as I like your teaching style....and no, the fingers and trolley are cool ways to connect with people.
@tundsdev
@tundsdev Жыл бұрын
Glad it was helpful!
@nylelevi750
@nylelevi750 Жыл бұрын
Can't believe the difference between CoreData and SwiftData. Thanks for the vid!
@tundsdev
@tundsdev Жыл бұрын
Glad you enjoyed it 👌🏾
@Louis-i4l
@Louis-i4l Жыл бұрын
Thank you so much for this video! I'm completely new to data persistence and to iOS development in general, so I found it super helpful.
@tundsdev
@tundsdev Жыл бұрын
Glad you enjoyed it 🤝
@DezDoesMTB
@DezDoesMTB 4 ай бұрын
Love the Deep Dish Swift shirt!!
@ampsonic
@ampsonic Жыл бұрын
How did you "collapse" the HStack to give yourself more room? That looks handy!
@tundsdev
@tundsdev Жыл бұрын
It’s a feature in Xcode called code folding, you have to turn it on via your preferences 👌🏾
@meet071
@meet071 Жыл бұрын
Smooth and clear video. Cheers 🥂
@tundsdev
@tundsdev Жыл бұрын
Thanks 🫂
@Itchster
@Itchster Жыл бұрын
Great tutorial and a starting point to tinker with Swift data. It's just a shame you can't appreciate the divine taste of a Bounty! 😆
@tundsdev
@tundsdev Жыл бұрын
Thanks, glad you enjoyed the vid & bounty’s aint it at all 😂
@alejmc
@alejmc Жыл бұрын
Just 9mins in but have subbed already, as someone that’s quite in diapers regarding SwiftUI and the surrounding Apple Frameworks this is quite concise and very well explained. I wonder if it is still alright to peek into CoreData (I also know nothing about it) since SwiftData will probably won’t be backported to previous iOS versions? I had started 100 Days of SwiftUI and one of the main things is “to not get distracted with too many things” but I guess WWDC23 and the new frameworks deserve a pause on that. Nevertheless, thanks for this… and for the chuckles too along the way 😅
@tundsdev
@tundsdev Жыл бұрын
Thanks and if you’re interested in Core Data in SwiftUI. Then I actually have a video that covers this. That may interest you Build Your Own Contacts App!!! | Core Data SwiftUI Tutorial kzbin.info/www/bejne/qIW7nHp5nJprrZI
@alejmc
@alejmc Жыл бұрын
@@tundsdev Thanks a lot, actually was just going to edit my own message as by the end of the video you had mentioned exactly that (the ailments of making comments without finishing the thing, my bad). Cheers once again.
@juanfrancisco9039
@juanfrancisco9039 Жыл бұрын
Very nice video. Could you show how to prepopulate a database with SwiftData and use this data into relationships?
@tundsdev
@tundsdev Жыл бұрын
Great suggestion, I’ll look into it👌🏾
@marclutke1900
@marclutke1900 Жыл бұрын
Firebase with Authentication would be great. 😅
@tundsdev
@tundsdev Жыл бұрын
Already in the works, but do you have anything specific you’d like to see? 👀
@marclutke1900
@marclutke1900 Жыл бұрын
@@tundsdev it also would be great to have CRUD operations in it. Because in SwiftData we’re switching from structs to classes and the behavior is different when I was testing it.
@alenkei1994
@alenkei1994 Жыл бұрын
Thanks for the video! Would love a tutorial on using SwiftData to cache data from an API call and display it in case the user is offline; this would also help to reduce unnecessary API calls.
@tundsdev
@tundsdev Жыл бұрын
I’ve already written a script 👀 It’ll feature a timed cache, but you can easily tweak it to handle offline connectivity
@m3zish
@m3zish Жыл бұрын
Thanks for the video, very well explained. Not the first one I see, but the more I see, the more information I get :) Seems you have part 2 already planned, I have ideas for part 3 and maybe 4 and 5 lol :) I have an app that is using Core Data, and I could simplify it if I were to use SwiftData instead, but I haven't figured out how to "migrate" the data from Core Data to SwiftDate. I made several attempts, nothing worked, so a video showing how to migrate from one to another WITHOUT losing any data would be great! Another video would be about sharing SwiftData between iPhone main app and Watch companion app. I tried too, but it always crashes, not sure if I'm doing it wrong or if Xcode beta is unstable. Lastly: I haven't found much information on iCloud storing of the information and syncing with other devices/OSs, that would be another video to consider :) Thank again for the information so far :)
@tundsdev
@tundsdev Жыл бұрын
Thanks, all good suggestions. So some i have planned content for, others will be part of a paid course. So just keep your eyes peeled 👀
@chrisjackson9733
@chrisjackson9733 Жыл бұрын
Another great video! Was wondering if you were planning on any videos overviewing Swift Macros. I think I have a general understanding but could use a clearer explanation. How are they different from property wrappers and/or packages?
@tundsdev
@tundsdev Жыл бұрын
Great suggestion, i’ll take a look into it for you 👌🏾
@ChileMamaLC
@ChileMamaLC 9 ай бұрын
What a great t-shirt! How might folks get an updated version of this for themselves I wonder? ;)
@tundsdev
@tundsdev 9 ай бұрын
By attending one of my fave conferences 👀
@wqlu3115
@wqlu3115 4 ай бұрын
thanks man, it’s very helpful!
@tundsdev
@tundsdev 4 ай бұрын
Glad it helped!
@fredsonsilva0007
@fredsonsilva0007 Жыл бұрын
The best content as usual. 👏🏽
@tundsdev
@tundsdev Жыл бұрын
Thanks ❤️
@danuff
@danuff Жыл бұрын
Thanks for the video!
@tundsdev
@tundsdev Жыл бұрын
Thank you for watching 🤝
@SiamakAshrafi
@SiamakAshrafi Жыл бұрын
Great explanation ... Thanks!
@tundsdev
@tundsdev Жыл бұрын
Thanks 👌🏾
@SettingUpTheChairs
@SettingUpTheChairs Жыл бұрын
Awesome vid! Is there a way to have the data sync with the apple watch using SwiftData?
@tundsdev
@tundsdev Жыл бұрын
Thanks & yh you’ll probs want to look into using app groups to pass data between different targets 👌🏾
@millie6781
@millie6781 11 ай бұрын
Bounty is so good thoughhhh😛(my favourite!!!) as much your video is helpful. Thank you for this amazing and well explained video☺
@tundsdev
@tundsdev 11 ай бұрын
Glad you enjoyed the video 👌🏾
@cloftis130
@cloftis130 Жыл бұрын
As always great video explaining a complicated topic. I do have a question…What is the key combination you use at about 17:03 mark to get the .sheet stub to change so that onDismiss is just in the closure? Thanks again Tunds.
@tundsdev
@tundsdev Жыл бұрын
Thanks & tbh I didn’t use a special key combination, I just hit enter 😅
@cloftis130
@cloftis130 Жыл бұрын
@@tundsdev Cool. I didn't realize it was that simple to get the code completion to get rid of some of the options. That'll save some time. Keep up the good work.
@ratatata6611
@ratatata6611 3 ай бұрын
Subbed!
@chukwumaugonabo1045
@chukwumaugonabo1045 3 ай бұрын
Good stuff!
@qianqian888
@qianqian888 Жыл бұрын
thank you~
@tundsdev
@tundsdev Жыл бұрын
Thank you for watching 👌🏾
@evroad
@evroad 11 ай бұрын
Looks like a good example for Swift Data, however I've got an error I can't get around. At about 7:40 in the CreateView file on line 14 is @State private var item = ToDoItem(). I get an error "Missing argument for parameter 'backingData' in call" Thoughts? Thanks.
@tundsdev
@tundsdev 11 ай бұрын
If you look at 2:15 have you forgot to add the default values to the initialiser? So when you create an instance of the the todo it doesn’t expect you to set every single param i.e title, timestamp, isCritical, isCompleted etc. This is what i think the problem is you’re facing
@evroad
@evroad 11 ай бұрын
@@tundsdev That's it, Thanks!! Now I'll see if I can get a little further along tonight!
@celicagirls
@celicagirls 5 ай бұрын
Hi at 7:14 i get a preview crash even after adding the model container has anything been updated since this was made thanks.
@tundsdev
@tundsdev 5 ай бұрын
Hi, this video was created during the beta. So there are a few changes around previews but everything else is still valid. One thing I would say is in the course you should look at the previews videos in it. And check out the sample code too in the description box 👌🏾 SwiftData Todo List App | SwiftData For Beginners | SwiftData In SwiftUI kzbin.info/aero/PLvUWi5tdh92wZ5_iDMcBpenwTgFNan9T7
@celicagirls
@celicagirls 5 ай бұрын
@@tundsdev Hi thanks will have a look at the previews videos much appreciated.
@tundsdev
@tundsdev 5 ай бұрын
Also pls check out the starter and final source code for the course especially the previews folder 👌🏾 github.com/tunds/youtube-content-2023
@Bankai3474
@Bankai3474 Жыл бұрын
In the WWDC keynote about making an app with SwiftData they used the @Bindable and they were able to save directly to the object, I tried doing the same but it doesn't like that for the Preview Window because the Bindable object (the object you're trying to persist) isn't initialized. Do you know anything about that?
@tundsdev
@tundsdev Жыл бұрын
So i actually have a video planned bout working with the new Preview macro & SwiftData coming out pretty soon to show you how to tackle this 👌🏾
@SlakySlaky
@SlakySlaky Жыл бұрын
Hello! How do we write unit tests for SwiftData?
@tundsdev
@tundsdev Жыл бұрын
This will be part of a paid course i’m working on, i still need to research/look into it
@maartenborsje
@maartenborsje Жыл бұрын
Error: Cannot infer type of closure parameter '$0' without a type annotation Can be resolved by changing: @Query( filter: #Predicate { $0.isCompleted == false }, sort: \.timestamp, order: .reverse ) private var items: [ToDoItem] to @Query( filter: #Predicate { $0.isCompleted == false }, sort: \.timestamp, order: .reverse ) private var items: [ToDoItem]
@ColeDano
@ColeDano Жыл бұрын
Thanks Maarten
@tundsdev
@tundsdev Жыл бұрын
👌🏾should also be in the pinned comments too
@ridholmes
@ridholmes Жыл бұрын
Thank, Tunds!
@tundsdev
@tundsdev Жыл бұрын
No, thank you for watching 🫂
@janstehlik3939
@janstehlik3939 Жыл бұрын
Question: if we create a @Model class with a custom struct as an attribute, and save this as an array (e.g. class Item { var details: [Detail] } ) how is this saved in the underlying Core Data? It sounds like an equivalent of a one-to-many relationship, but without a second object; which I can't wrap my head around
@tundsdev
@tundsdev Жыл бұрын
Based on what you’re saying you’d possibly want to create a relationship between the two, using the relationship macro. I actually have a script/vid planned to show this, but currently in the first Xcode 15 bets deletes with relationships crash at lot. Once that is more stable I will release the vid, since it goes over one to many relationships 👌🏾
@janstehlik3939
@janstehlik3939 Жыл бұрын
@@tundsdev I understand we can create a one-to-many relationship using a macro. My question is more about the new composite attributes, and whether they can replace a to-many relationship. Another example: class Car { var wheels: [Wheel] }, where Wheel is not another class, but a struct, and saved (somehow) as a composite attribute.
@tundsdev
@tundsdev Жыл бұрын
Ahhhh ok got you, so I saw this in the modelling your data video. I’m not too sure on the benefits/differences something i’d have to explore and checkout myself since its still early days I have a project where i can mess around with your example let me play around & find out for you? 👀
@janstehlik3939
@janstehlik3939 Жыл бұрын
@@tundsdev that would be amazing, thanks! IF this is possible, it could be important, because we could replace a to-many relationship and therefore avoid faulting a second table into memory when fetching. This could result in significant performance gains for large datasets.
@tundsdev
@tundsdev Жыл бұрын
So i’ve not tested it yet. But been compiling code in my brain 😅 And I think what would happen is that you’d basically have the data associated with the model. But I do think the model would have to be a codable, since you’re not defining another model. My guess would be SwiftData would just flatten it and save it. I think examples like where a to do could have a category you probs wouldn’t want to do this since you’d want a model where you can query all categories. If you had them all associated with a model as an array of structs you’d have to get all the to do’s and then the categories in them you can see where the problem is starting. So those relationships help with maintaining data integrity. I do think it would be useful for things like configurations i.e lets say a to do had a set of configurations like priority, tags, location to trigger etc. Since you dont need to query stuff like this. These are my thoughts/thinking
@LebenWerden
@LebenWerden 5 ай бұрын
Hello, what about @StateObject @ObservedObject @Binding @EnvironmentObject @Published Better avoiding them?
@sergpryimachuk
@sergpryimachuk Жыл бұрын
C'mon, I like Bounty! 😆
@tundsdev
@tundsdev Жыл бұрын
*Shakes head in disappointment*
@teakodo
@teakodo 6 ай бұрын
For those getting Cannot infer type of closure parameter '$0' without a type annotation you need to add or in the video's case @Query( filter: #Predicate { $0.isCompleted == false }, sort: \.timeStamp, order: .forward ) private var items: [Item]
@tundsdev
@tundsdev 6 ай бұрын
I added a pinned comment & this to the description explaining this btw, it was a change made during one of the xcode betas 😅
@teakodo
@teakodo 6 ай бұрын
@@tundsdev thank you ! didn't see my bad
@hannahn9464
@hannahn9464 10 ай бұрын
specific
@iwy2th
@iwy2th Жыл бұрын
thank !!!From Viet Nam !
@tundsdev
@tundsdev Жыл бұрын
Thank you, glad you enjoyed it 👌🏾
@kenturnbull9679
@kenturnbull9679 Жыл бұрын
Good Tutorial. NavBarTitle not showing up on edit view. Small thing...$0.isCompleted == false ; Simpler ==> !$0.iscompleted.
@tundsdev
@tundsdev Жыл бұрын
Thanks & I actually prefer explicitly stating the condition its way more readable imo 👌🏾
@tundsdev
@tundsdev Жыл бұрын
Also with the Title bar not showing up, I just forgot to add the NavigationStack. You can easily add that in if you want too 👌🏾
@kenturnbull9679
@kenturnbull9679 Жыл бұрын
Too many years of Oracle for me. Now I have to get used to this way of doing things...although SwiftData is a lot better than CoreData@@tundsdev
@evangelosspyromilios5994
@evangelosspyromilios5994 Жыл бұрын
Thanks for the video mate! Having spent hours and hours to learn CoreData is simply amazes me how easy things are now with SwiftData! A 'part 2' of the video could include how to make relationships between models ;-)
@tundsdev
@tundsdev Жыл бұрын
Thanks and lol that is Part 2, the only thing deleting items with relationships crashes a lot at the moment, and i don't want to give y'all an half asses video so I hope they resolve this so that I can give you the best possible vid. Make sure you checking out the playlist since i'll be releasing a ton of videos about this topic on there as this app starts to grow 🤝
@tundsdev
@tundsdev Жыл бұрын
Here is the vid, explaining relationships btw 👀 kzbin.info/www/bejne/lYKwkp-LfLmAaqcsi=NRPtyNTXkH9M3lre
@sameershaik9110
@sameershaik9110 3 ай бұрын
How do i get ur code from github?
@profgallaugher
@profgallaugher Жыл бұрын
Great work. You do such good work. Swift on!
@tundsdev
@tundsdev Жыл бұрын
Thanks 🫂
@allenwixted1992
@allenwixted1992 10 ай бұрын
At 7:14 I get a crash when adding the model and container. "Failed to find a currently active container" comes up in the preview. Any ideas?
@tundsdev
@tundsdev 10 ай бұрын
Have you set the modelContainer in the Previews? If not then you'll more than likely see this crash
@allenwixted1992
@allenwixted1992 10 ай бұрын
@@tundsdev yeah that was my first thought also. Funnily, it works from the content view when pulling up the sheet, I can see the create a task view perfectly, but not via the create view itself
@dibjr
@dibjr 10 ай бұрын
@@allenwixted1992 I have the same issue running Xcode 15.0.1, crashes in ModelContainer.swift, failed to find a currently active container for ToDoItem. It runs ok in the simulator. It just crashes in the preview.
@julianjpg
@julianjpg 7 ай бұрын
You are awesome man! Thanks for saying my day!!! Wait a minute…. Ma hol coding life!! 👏🏾👏🏾👏🏾👏🏾👏🏾👏🏾
@tundsdev
@tundsdev 7 ай бұрын
Any time!
@aerospaceexportsincorporat2753
@aerospaceexportsincorporat2753 Жыл бұрын
Great video, thank you for sharing. Any chance in the future you could teach on how to add a “Select All” feature to this app to allow for deleting multiple ToDos at once? Again, well done!
@tundsdev
@tundsdev Жыл бұрын
Thanks & yh i’ll consider it 👌🏾
@pgong415
@pgong415 Жыл бұрын
Thanks for your efforts to show how to use SwiftData to build a ToDo app, where essential concepts and techniques are demonstrated. Great! You really help me sort out one of my problems - how to update items in SwiftData without using the trump merge policy. and I found the solution is so easy. Yes, of course because of beta version, the updating view can not be easily previewed, i believe the apple engineers can get it sorted asap before the official version is released. Bravo!
@tundsdev
@tundsdev Жыл бұрын
Glad you enjoyed it !
@Pete-ek9dw
@Pete-ek9dw 28 күн бұрын
thank you sooooo much!😀
@jlock4545
@jlock4545 Жыл бұрын
Hi Also get errors when I update the ContentView about 9:50 into the video. please help
@tundsdev
@tundsdev Жыл бұрын
Hey, you’ll need to be a bit more specific what errors are you getting?
@abdouett3676
@abdouett3676 Жыл бұрын
Thank you for the video! To format a code to multiple lines, it’s actually possible scan the desired code > Right clic > Refractor > Format to multiple lines.
@tundsdev
@tundsdev Жыл бұрын
Glad you enjoyed the video👌🏾
@chezchezchezchez
@chezchezchezchez Жыл бұрын
@@tundsdev but did you enjoy his tip? Lol.
@TheBishopOfBarton
@TheBishopOfBarton Жыл бұрын
Great video - really well explained. Thanks man.
@tundsdev
@tundsdev Жыл бұрын
Glad you enjoyed it!
@benjaminanic7899
@benjaminanic7899 11 ай бұрын
Do you have any videos on developing an app with the open ai GPT API?
@tundsdev
@tundsdev 11 ай бұрын
Nope not atm no
@michanierebinski1423
@michanierebinski1423 Жыл бұрын
Thanks for the vid. Quick and fun tutorial
@tundsdev
@tundsdev Жыл бұрын
Glad you enjoyed this 👌🏾
@solidenix
@solidenix 9 ай бұрын
Great Video ! Question, what would you change if you wanted to add additional criteria for sorting ? for example to sort by completed AND by timestamp?
@sxmiotb2834
@sxmiotb2834 Жыл бұрын
I love you man. Thank you so much
@tundsdev
@tundsdev Жыл бұрын
Appriciate it 🫂
@iLoveAppl3947
@iLoveAppl3947 7 ай бұрын
very good bruder
@tundsdev
@tundsdev 7 ай бұрын
Nice one brudda
@highlyevolved4977
@highlyevolved4977 10 ай бұрын
How dare you diss bounty!! Unsub nowwww
@gmjelle
@gmjelle Жыл бұрын
Hi @tundsev, did you manage to make a model both @Model and Codable at the same time?
@tundsdev
@tundsdev Жыл бұрын
Yep, its coming out this sunday 👌🏾
@MarvelousLXVII
@MarvelousLXVII Жыл бұрын
Very nice video. Is there a way to create a query with predicates on the fly i.e. someone choosing what field to search-by?
@tundsdev
@tundsdev Жыл бұрын
Thanks & at this moment in time no. But if there is a way in the final release then i’ll do an updated video 👌🏾
@MarvelousLXVII
@MarvelousLXVII Жыл бұрын
@@tundsdev I just saw this in the docs--I think it's pretty much what I was thinking about. let simpleFood = #Predicate { recipe in recipe.ingredients.count < 3 }
@vanylaskywalker
@vanylaskywalker Жыл бұрын
I've been using structs extensively.. because it was recommended to use codable structs instead of classes.. now do I have to switch everything to classes? Struct just went out of trend?
@tundsdev
@tundsdev Жыл бұрын
Apple recommends using classes in all of their sample code, probably because of the changes they’re made with the new Observation framework. For Models with SwiftData i’d stick to using classes 👌🏾
@stanleyhuang2186
@stanleyhuang2186 Жыл бұрын
is "TodoItem with @Model" still a class ? I saw you use @State. I am confused why it doesn't use @StateObject.
@tundsdev
@tundsdev Жыл бұрын
Reason why is because @Model is built ontop of the new @Observable macro which is only meant to be used with @State. It’s part of the new SwiftUI data flow coming in iOS 17 that works with classes for observing data. I’ll have a video out for it pretty soon 👌🏾
@chezchezchezchez
@chezchezchezchez Жыл бұрын
Would someone help me with the logic of deleting an item in the details view. I’m talking about my code, not his code. When I delete in the main view, it’s fine. But obviously, in the detail view, when you delete the item, you’re working with, the controls can’t update, because there’s no item any longer. It deletes fine, but then I get an error. What I really want, is to delete it, and go back to the main view. But it doesn’t work. I know about dismiss, and that works (when I’m not deleting an item) I can’t get deleted, and dismissed to work together without an error. Thanks so much
@tundsdev
@tundsdev Жыл бұрын
Hey, so when you call the dismiss function right after delete. What error are you getting? This should work which is weird
@chezchezchezchez
@chezchezchezchez Жыл бұрын
@@tundsdev Thanks for getting back to me. I’m at work now. I’ll edit this text with the error message when I get home. Wait a sec. I’m a NOOb. I don’t remember seeing an error. I think it went back to the “main” view and it was just blank screen. Anyway I’ll get back to you. I’m not good at seeing errors in the list at bottom, yet.
@chezchezchezchez
@chezchezchezchez Жыл бұрын
@@tundsdev Ok I made a YT vid for ya explaining it a bit: kzbin.info/www/bejne/oZjKgIOGgrCgjNU
@ViktorEvil
@ViktorEvil Жыл бұрын
is it possible to have multiple sort options? on the @Query at the same time i.e I want to sort by name but if they are the same then use the time
@tundsdev
@tundsdev Жыл бұрын
So at the moment in time nope, it's not possible since you can only define a keypath on a property and sorting direction. If you wanted to do that you'd be better off copying what i did with my filter logic in this video so it can dynamically filter and sort the data or file a feedback with Apple so they can add this an improvement.
@stephenjennings2256
@stephenjennings2256 Жыл бұрын
At this point would your bother learning core data or focus your energy in swiftdata?
@tundsdev
@tundsdev Жыл бұрын
I do think SwiftData is great, there’s still a few things that need ironing out. But my personal apps will all be using SwiftData going forward, WWDC24 is where I think it will be standard imo
@kenturnbull9679
@kenturnbull9679 Жыл бұрын
👍👍 + 2 jam butties
@tundsdev
@tundsdev Жыл бұрын
You're a man of good taste 🤝
@haydgately2109
@haydgately2109 Жыл бұрын
What is the best approach for waiting to see if the insert was correct before moving to a new screen, when there is no async/await for SwiftData? :) Thanks
@tundsdev
@tundsdev Жыл бұрын
Not too sure on you mean by the insert being correct? As soon as you insert it’ll be in memory so the new changes will be there and automatically persisted (as long as autosave is enabled) so when you go to the next screen the object should be there already
@haydgately2109
@haydgately2109 Жыл бұрын
@@tundsdev hi sorry I meant success, not correct. So you do insert, but show a loading indicator whilst it does it, but also show and error if it fails? Great video! Any chance there could be a follow up syncing to cloudkit? 😇
@tundsdev
@tundsdev Жыл бұрын
So with swiftdata inserts are so instant you probs wouldn’t even need a spinner tbh. And cloudkit will be part of my paid course 👌🏾
@jimmason4723
@jimmason4723 Жыл бұрын
Brilliant mate, thanks for showing this.
@tundsdev
@tundsdev Жыл бұрын
Thanks ❤️
@danielaupont9468
@danielaupont9468 Жыл бұрын
Great video! Can’t wait to try this out 🔥
@tundsdev
@tundsdev Жыл бұрын
Thanks my man 🫂
@ColeDano
@ColeDano Жыл бұрын
Lovely stuff Tunds!
@tundsdev
@tundsdev Жыл бұрын
Thanks ❤️
@franksolleveld2909
@franksolleveld2909 Жыл бұрын
Have you noticed the Missing argument for parameter 'backingData' in call whenever making the @State property in 6:38? I imported SwiftData and declared a modelContainer in the Preview. Unsure what's happening
@tundsdev
@tundsdev Жыл бұрын
I have not noticed that error with the Xcode15 beta. Maybe give the project a clean, clear derived data, also in the description box is the complete project so you can compare. But i’ve not used that backingData property, since i have a init where i set the default params for each property so I can just create an empty to do 👌🏾
@franksolleveld2909
@franksolleveld2909 Жыл бұрын
@@tundsdev yeah i noticed your init aswell. Filed a bug report for it, will remove it if I noticed something i did that caused it 😂
@tundsdev
@tundsdev Жыл бұрын
I’m curious if my final project has the same issues on your machine 👀
@franksolleveld2909
@franksolleveld2909 Жыл бұрын
Apparently I had to make it private ;-)
@thilotech
@thilotech Жыл бұрын
@@tundsdev Just out of curiosity since I faced the same issue when not having default values, why does this happen? Is this intentional?
@jlock4545
@jlock4545 Жыл бұрын
Hi Great work! I am using XcodeI 15.0 and I am having an issue on the #Preview when I add the '.modelContainer(for: ToDoItem.self)' in the CreatView file? The error Xcode gives me is this: MyToDos crashed due to fatalError in ModelContainer.swift at line 144. failed to find a currently active container for ToDoItem Does anyone know how to fix this please or is it a bug? Thanks
@tundsdev
@tundsdev Жыл бұрын
Hmm that should work, can you check out the free source files to compare what may be different and also make the changes that I pinned in the comments section on this video too. github.com/tunds/youtube-content-2023/tree/main/SwiftData%20Is%20Way%20Easier%20Than%20CoreData%20😇%20%7C%20Build%20A%20Todo%20app%20using%20SwiftData I also have another video which you should check out which goes over a better way of handling SwiftUI previews with SwiftData kzbin.info/www/bejne/oHSmZKyrmJqAi6s Hope this helps
@romanyefimets454
@romanyefimets454 6 ай бұрын
i seem to have the same error, anyone figure it out?
@tundsdev
@tundsdev 6 ай бұрын
Hey you’ll 100% want to check out my video that goes over working with SwiftData and the Previews which covers an even better way of handling this the link is above ☝🏾
@romanyefimets454
@romanyefimets454 6 ай бұрын
@@tundsdevnot sure which video you are referring to, i see links to the playlist.
@tundsdev
@tundsdev 6 ай бұрын
@romanyefimets454 How To Use SwiftData with Preview | SwiftData Tutorial | #10 kzbin.info/www/bejne/oHSmZKyrmJqAi6s
Swift Data Relationships 🚀 | SwiftData Tutorial | #2
26:52
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17
Players vs Corner Flags 🤯
00:28
LE FOOT EN VIDÉO
Рет қаралды 68 МЛН
How THIS instagram story kills your phone.
12:46
Mrwhosetheboss
Рет қаралды 15 МЛН
1.  Camera Photos SwiftData: DataModel and View Setup
20:46
Stewart Lynch
Рет қаралды 2,2 М.
SwiftData Basics in 15 minutes
15:18
CodeWithChris
Рет қаралды 46 М.
Build a FULL Web App With Claude With 2 SCREENSHOTS!
17:36
Riley Brown
Рет қаралды 155 М.
Swift API Calls for Beginners (Networking) - Async Await & JSON
25:35
My thoughts on framework after daily driving it for 2 years
16:34
Louis Rossmann
Рет қаралды 708 М.
1. SwiftData CRUD Operations
42:40
Stewart Lynch
Рет қаралды 27 М.
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17