How to use Core Data with @FetchRequest in SwiftUI | Continued Learning #14
Вставка
- Опубліковано 22 сер 2024
- In this video we jump into the world of Core Data! We will first create a new Xcode project, review some of the template Core Data code that Apple provide us, and then we will customize the code for our iOS application. In this video we will implement CRUD functions by learning how to Create, Read, Update, and Delete data within Core Data. As noted in the title, this video explores how to use the @FetchRequest, which enables us to easily connect Core Data to our SwiftUI View. In the next video, however, we will learn another implementation of Core Data using MVVM architecture - that no longer uses the @FetchRequest. Both implementations are useful and good to know!
Next video: • How to use Core Data w...
Last video: • Sort, Filter, and Map ...
🤙 WELCOME BACK 🤙
WEBSITE: www.swiftful-t...
DISCORD: / discord
GITHUB: github.com/Swi...
SAY THANKS: www.buymeacoff...
I intensionally missed this tutorial year ago, and now I regret doing that. I did it because I was afraid of Core Data even without knowing what it was. But now it just looks simple and easy to understand. Thanks Nick.
I love the "new"(from the Beginner course) edits! Honestly man, you are a life saver!
Happy to help!
I watched all your 77 beginners and now halfway through this . Great job, right speed of explaining. Thanks for that. I honestly would be lost without you as you are addressing the right topics in the right way. One thing I am really struggling with in my app is passing data around. Your courses are great for understanding, when it gets more complex though - do you have an advice how to optimize e.g. environment, the new observable class, bindings, etc. I am often not sure which is the best way of using what when. Any video on that topic would be great.
Thanks for your great training: My first goal is to make a 'Simple' journal app. Tag each entry with the current date:time. Save the entries automatically into CoreData. Recall entries in ScrollView based on Date. Then later automatically tag each entry with current weather:temperature; my current location during entry, then edit entries, allow for dictation, eg. as my knowledge increases.
I'm back watching Continued Learning. You have the best show on the internet! The best part is, every time I watch, it's like the first time! hahaha
hands down the most useful swiftui videos on youtube
Wow, thanks Umar! :)
Thanks. It is the first time that I see somebody who mark core data in the project and use it, the others remake everything
Yea, it's great that Apple gives us some template code but it can be hard to understand. I'm happy this helped!
Great explanation, thank you! It's already 2023 and your tutorial still top, good job Nick👍
I really can't thank you enough, you are a savior!! Keep the awesome work!! :)
The best channel, there is nothing on the Internet about this topic!
Thank you Nick for the preface at 0:55. It clears it up that I don't need to have both an @FetchRequest variable and Core Data view model at the same time. Very neat 🤝
By far the best SwiftUI channel out there! You deserve a lot more subscribers!
WooHoo!! Core Data! I've been looking forward to this one! Thanks Nick. Great video!
You are cruising though these playlists 😂🥳🥲
You just make core data easy to me ;thanks so much man
Thanks for your videos! Keep 'em coming👍🏻
Thanks Tech Rag, will do! :)
Probably the best video tutorial/walkthrough I have watched, really nice to see even the standard core data code in the project really well explained, thank you.
Question: Do you have a video or could you make an example of using multiple entities and also showcasing one-to-one, one-to-many etc. relations, how it works and how it can be used?
/cheers
Well, I kept watching your videos and it seems like one on core data relationships is coming 😂 thanks mate
Very useful information, thanks!
Thanks so much bro I learn swift in project ,swiftui ,filesytem ,GCD ,core data from you ,…..
Such an excellent video! Well done! Thank you
Thanks again Bob!!
Thanks,.. I was so afraid to start with CoreData, because it looks so complicated for me. Believe I will understand it with You finally.
Yes, it can definitely be challenging. Let me know if you have any questions Charlie :)
@@SwiftfulThinking Hi, I have questions :-) If You have model data (array with inserted data), can You some simply way insert it to entity in one step (structure is the same), or You have to pass array in cycle and insert each item separately? How You can delete all items in entity? Thank You
@@SwiftfulThinking And other very important thing is to get number of items in entity, ... is empty or not.?
Thank you for sharing your knowledge...
Glad you're enjoying the videos :)
Hello! love your tutorials, it's so easy to understand compared to many others I have watched. I've already started with firebase for the backend and I was wondering if you've ever thought of doing a tutorial on that? Thanks a lot!
Hi Amy! Yes, I am planning on doing a Firebase course soon. I just haven't gotten to it yet!
@@SwiftfulThinking Awesome! Love your videos!
Im having a lot of trouble following along, there's been an update and trying to do exactly as you do the view isn't updating with the newFruit to the list. I've searched and I can't seem to find what I am doing wrong
他是真的想教会我,我哭死。
He really wants to teach me, I cry to death。
ty
Hey men, I want to be like you when I're big!
Your cpu fan is 🐐
It's not good 😭
Question: I can NEVER pick color literal! Is the a setting you have to adjust in the menus to get that to work? As always, love the great content/education!
can you always add core data to an already existing project later on?
Yes!
Thanks 👍
No problem 👍 You are always watching my latest vids! Thanks!
22:05 I cant append new item (orange). Every line of codes are same but it doesnt work on canvas for me. Actually it works on simulator. Does anyone know why?
A huge thanks for this series, it helps a lot! While in my trying, I wonder what are the best practices for making core data works with the preview in SwiftUI, in other words, how to preview my customized view component with different (mocked) input data (for example, a blank state, and a state with some data) if this view directly pull data from the core data database using the @FetchRequest?
I am getting the error "executeFetchRequest:error: A fetch request must have an entity.", although I had implemented the same as your code.
Awesome work! Could you please help me, if I have three Entities called Country, State, and Districts. I would like to filter Districts entity depending on selection of State. How it should be done?
Everything works when I use a List to render out the words...but what if I want to create card components? I tried and I only get the last word, not all the words from Core Data
Hi Nick, I found there is one miss function you didn't introduce in coreData: "move", I can add/ delete/update item, but when I want to do .onMove function, I found when I move the ForEach .onMove it will back to the original order in the entity. even I add saveData() after func move, it more badly afterI click Done it immediately back to the origin order. Can you help to have some advise, or core data cannot use .onMove function?
Following Compiler error appear in the CoreData template app:
1. Generic parameter 'Content' could not be inferred' (in the ***App.swift)
2. Cannot find 'FruitEntity' in scope (in Persistence.swift and ContentView.swift)
I have followed the same steps as in the tutorial.
Thank you so much!!! 🙂 I wanted to ask you, how to decide when to use core data or remote data?
This is a big question but I'll try to simplify... If there is data that (1) other users need access to, or (2) you want to be saved for the current user to use across multiple devices, then you need to store it in a remote location so that other devices can access it. If it's data only for the current user on the current device, then you can save it locally. There are several options for saving locally, most common is (1) UserDefaults for small pieces of data, (2) FileManager for large data blobs, such as Images/Videos/Audio, and then (3) CoreData when you have a larger data sets that you want to save, such as data Models in your app.
@@SwiftfulThinking Thank you for your quick reply. Very clear answer. You’re great 👍🏻
Hey there! Is there a possibility to put the tapGesture on the entire row?
Hey Nico, yea you should be able to add a TapGesture to any View in Swift (you can't put it on the ForEach but you can put it on a view inside the ForEach closure).
I dont know why at FecthedResults the editor says that item is not in the scope
Did you figure it out? You might have to restart Xcode. It happens sometimes..
Core Data is the most difficult topic I've ever happened to deal with.
Yea it can be challenging haha. I hope this video helped.
@@SwiftfulThinking yeah it helps a lot.
guard let index = offsets.first else { return } - (...index is not optional)
This is extra code, completely useless((
Nick
Hammer Lam