Core Data Tutorial - Lesson 5: Entities and Relationships

  Рет қаралды 29,187

CodeWithChris

CodeWithChris

Күн бұрын

Пікірлер: 122
@CodeWithChris
@CodeWithChris 4 жыл бұрын
QOTD ⚡ What app are going going to build with your new Core Data skills? Let me know below! 👇 Check out my newly launched CWC+ program! ➡️ cwc.to/plus-qotd
@Ipadstands
@Ipadstands 2 жыл бұрын
Thanks ! Apple should give you an award for producing such useful and professional content ! Plus some money too !
@CodeWithChris
@CodeWithChris 2 жыл бұрын
Cheers, thanks for the support! -Arthur
@bhanusreebukya2621
@bhanusreebukya2621 3 жыл бұрын
Thanks alot for this Chris the best tutorial ever , crisp and clear , beginner friendly.
@CodeWithChris
@CodeWithChris 3 жыл бұрын
What a humbling comment. Thank you so much! -Arthur
@peronawu9265
@peronawu9265 4 жыл бұрын
By watching the core data lesson 1-5 I learnt a lot, thanks. You explained everything very clearly!
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Great to hear! You're very welcome! - Kat
@fatemashams7488
@fatemashams7488 4 жыл бұрын
Simple, elegant, and straight forward! Thanks, man!
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Ooooooooh! Thank you! @AdrienVillez
@mountainsmusicandcode
@mountainsmusicandcode 4 жыл бұрын
Brilliant stuff Chris - big thanks - CoreData had been doing my head in, seeing it from a fresh perspective really helps.
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Cheers, Robin! Thanks for learning with us! :-) -Arthur
@stopitwithusernames
@stopitwithusernames 3 жыл бұрын
WOW! Thank you! I've been struggling with this for, well, longer than I care to admit. Very clear, clean explanation on the different parts and how it works. Thank you!!!!!!!!!
@CodeWithChris
@CodeWithChris 3 жыл бұрын
Thank you as well for your kind support! :-) You guys are the best! -Arthur
@shubham5399
@shubham5399 4 жыл бұрын
Thank you so much for this wonderful tutorial series. Love from India.
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Thank you so much for your support! :-) -Arthur
@Rose-jp7dm
@Rose-jp7dm 4 жыл бұрын
Thank you, Chris!! Your tutorials are always helpful!!
@CodeWithChris
@CodeWithChris 4 жыл бұрын
The magic of KZbin! 😇 @AdrienVillez
@raiyanrizwan2353
@raiyanrizwan2353 2 жыл бұрын
You always have exactly what I need. Thank you so much!
@CodeWithChris
@CodeWithChris 2 жыл бұрын
You are so welcome! :) -Arthur
@deltawhiskey6243
@deltawhiskey6243 4 жыл бұрын
Really great series Chris! Thank you. I have a much better understating of Core Data now.
@CodeWithChris
@CodeWithChris 4 жыл бұрын
That's awesome to know. You'll only get better from here. Stay safe! :-) -Arthur
@ilovepickles7427
@ilovepickles7427 3 жыл бұрын
Really great series! Thanks so much. I'd love to have another video on your thought about how to mock your data model for testing/experimenting/unit testing.
@CodeWithChris
@CodeWithChris 3 жыл бұрын
Appreciate your support so much! :) -Arthur
@pokiishere-sebastian2126
@pokiishere-sebastian2126 4 жыл бұрын
Awesome video as ever 😊. Thanks a lot!
@CodeWithChris
@CodeWithChris 4 жыл бұрын
So nice of you, welcome! - Kat
@gallivantdiaries9457
@gallivantdiaries9457 3 жыл бұрын
Tegridy 💪🏽 great series thank you 🙌🏽
@CodeWithChris
@CodeWithChris 3 жыл бұрын
Thank you so much! All the best! :-) -Arthur
@shubhamagarwal9147
@shubhamagarwal9147 4 жыл бұрын
Thank you, Chris, for providing so much valuable things regarding Core data and it gives me a boost to work on core data, Can you also provide some basic Ideas for Core Data Application so I can convert this knowledge into a live example. Thank you so much for all these videos.
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Ok, we might do a video on this one. Thanks for you great suggestion and for your support. :-) -Arthur
@harisri485
@harisri485 4 жыл бұрын
Nice Explanation Chris..if u don't mind, can u make a video on core data deletion rules.
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Thanks! You can add your tutorial requests here cwc.to/request - Kat
@Comic-p1u
@Comic-p1u 4 жыл бұрын
This helped me a lot Thank you
@CodeWithChris
@CodeWithChris 4 жыл бұрын
You're welcome! Glad it helped! - Kat
@rajatalha2771
@rajatalha2771 4 жыл бұрын
Thank you ! this helped me alot
@CodeWithChris
@CodeWithChris 4 жыл бұрын
You are so welcome! Keep on having fun! :-) -Arthur
@tora0neko
@tora0neko 3 жыл бұрын
Saved my skin, this video
@CodeWithChris
@CodeWithChris 3 жыл бұрын
Glad to know. Thanks for learning with us! -Arthur
@francisa9756
@francisa9756 4 жыл бұрын
very helpful thank you!
@CodeWithChris
@CodeWithChris 4 жыл бұрын
You're so welcome, Francis! Glad to know that we helped you! :-) -Arthur
@benradler
@benradler 4 жыл бұрын
Would love to see an extension of this series that covers the (now documented-by-Apple, albeit poorly) "Mirroring a Core Data Store with CloudKit" functionality first demo'ed in 2019 WWDC.
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, cloudkit is part of our planned tutorials to release so watch out for it in the future. for the meantime maybe you can check on our community forum is anyone can help you, just head on over to codecrew.codewithchris.com - Francis
@benradler
@benradler 4 жыл бұрын
CodeWithChris thanks, so to clarify you plan to cover coredata and CloudKit together, correct?
@elemento_arts
@elemento_arts 4 жыл бұрын
Hi, great vids. Can you explain how to adapt the code to support local and Cloud databases? Thanks
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, usually you might need to implement cloudkit for that one, but usually cloud database like Firebase can be used as both local and cloud (because of offline capabity), so your data gets synced once you go online - Francis
@vidarkro87
@vidarkro87 3 жыл бұрын
Thank you so much! This is brilliant :) I have one question. Can you show how to properly use NSSecureCoding when using transformable in CoreData?
@CodeWithChris
@CodeWithChris 3 жыл бұрын
You're welcome! We'll take note of your suggestion!
@drakip4683
@drakip4683 3 жыл бұрын
Thank you very much!
@CodeWithChris
@CodeWithChris 3 жыл бұрын
Cheers, Draki! Thank you for being here! -Arthur
@antonstandwerth
@antonstandwerth 4 жыл бұрын
Could you do a tutorial on using Core Data (with relationships) using SwiftUI and MVVM-pattern
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Great suggestion! Can you add this here please: cwc.to/request Thanks! - Kat
@LebenWerden
@LebenWerden 4 жыл бұрын
Hello, thanks for LEsson 4 and 5. Lesson 6 is coming soon?
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hi there, this is the last lesson in the series. :) - Kat
@FishySwordfish
@FishySwordfish 4 жыл бұрын
Tysm for this series Chris! I was wondering if it is possible to get specific data by fetching it from a relationship between two separate entities and pass it to a ViewController which then gets displayed in a CollectionView.
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, yes it should be possible thats how relational databases work but you might need to "combine" them inside a single Dictionary or Array - Francis
@Nate-ns8rw
@Nate-ns8rw 4 жыл бұрын
When a developer is releasing a new app version, does the developer have to do anything to make sure that user data is not lost? For example if version 1 is using core data and data is stored on the user's device, then they upgrade to version two, to they still have their data? (Assuming that the only changes were visual and not related to the database)
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, yes you should be able to keep your data even if you "update" your app. unless you do something on startup to "overwrite" the database - Francis
@rudolphhock1155
@rudolphhock1155 3 жыл бұрын
Good question, forward thinking.
@dr.craigcurphey4829
@dr.craigcurphey4829 8 ай бұрын
Hey Chris - how would I save a Person object that is related to a family? Tryint to access addToPersons in the Family extension makes Xcode angry. Thanks!
@RohitPatil_Tech
@RohitPatil_Tech 4 жыл бұрын
Hey Chris, Awesome series! Very helpful!! Could you please suggest me some good resources on learning NSOperation ? Thank you 😁
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, upon a quick google search i suggest looking at blogs and articles like this one www.appcoda.com/ios-concurrency/ - Francis
@abdullahalnutayfi8103
@abdullahalnutayfi8103 4 жыл бұрын
Hi, I followed your course i n SwiftUI, but in this course (Core Data), you chose storyboard, should I learn both of them in parallel (Storyboard and SwiftUI) ?
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Storyboard has been around for a long time and is also the beginner friendly way to learn to code. Since we focus on Core Data, using Storyboard is a good way to really focus on Core Data and not spend 70% of the lesson building UI programmatically. We have 100% SwiftUI content coming soon at www.codewithchris.com @AdrienVillez
@abdullahalnutayfi8103
@abdullahalnutayfi8103 4 жыл бұрын
@@CodeWithChris thanks for response.
@Nate-ns8rw
@Nate-ns8rw 4 жыл бұрын
I made the mistake of naming creating entities in an existing project with the same names that I had for my Structs. It blew up. Took a couple minutes to figure out why. The easies work around was to name the entities "SomethingEntity" while my struct remained "Something". Then once I was using the entities, just deleting the structs and then renaming the entities from "SomethingEntity" to "Something"
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, its great that you where able to debug the problem with your code. keep it up :) - Francis
@dr.craigcurphey4829
@dr.craigcurphey4829 8 ай бұрын
I made a Shopping Caddy app that uses iCloud, now I am gonna recreate it for core Data so it is non-sharable.
@georgegerardis4910
@georgegerardis4910 4 жыл бұрын
Hi Chris, Your lessons are excellent! I have been helped a lot here knowing swift programming. I have a question about Core Data. I have followed all 5 lessons and after I have build an App using CoreData. All functions perfect until I relaunch my app. after re-launching the app all data has been LOSTED! Why this is happening? Ofcource the "(UIApplication.shared.delegate as? AppDelegate)?.saveContext()" exists in SceneDelegate at function : "sceneDidEnterBackground" can you explain why or can you check the lessons app? Anyway I would like to thank you for your help George Gerardis
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, did you remember to put in your permissions in order to save data? maybe you missed a step in the early parts of the video - Francis
@georgegerardis4910
@georgegerardis4910 4 жыл бұрын
Hi Chris, Finally I have solved the problem. Because we are using NSPersistentContainer the Lightweight migrations are enabled by default. I didn't know that so, I use NSPersistentStoreDescription for migration which cause the problem. When I removed that all works like a farm! One more thing. Can you prepare lessons about Push Notifications with Firebase? This will be very helpful for all of us. Thank you again. George
@ecocreate
@ecocreate 9 ай бұрын
If you successfully save, and then Maggie's name changes and you need to update the person entity, but the family Maggie is in does not, when you save the context, I would assume you do not have to save/update the relationship again. Is that correct?
@ushadesai6306
@ushadesai6306 3 жыл бұрын
Can we change from Manual to Class Definition Code generation type at a later time. How to make NSManagedObject classes generated this way work for SwiftUI. I am working on a SwiftUI app currently where I have one-many relationship between entities. Your lessons are very helpful.
@CodeWithChris
@CodeWithChris 3 жыл бұрын
"Hello, i suggest checking out our updated course which is all about SwiftUI (KZbin lags behind in terms of content) check out the contents of our courses here learn.codewithchris.com like this updated database course that we have that uses Firebase and CoreData for SwiftUI learn.codewithchris.com/courses/databases - Francis"
@nicolagabriel8520
@nicolagabriel8520 3 жыл бұрын
Hei, i have 2 entities and when i try to add some data to just one of them the other one gets a entry with blank data.What can i do about it ?
@CodeWithChris
@CodeWithChris 3 жыл бұрын
"Hello, try double checking if the ""data type"" is actually the same as intended, usually a mismatch might cause it to just put a ""null"" or blank instead of crashing - Francis"
@saenkoandrew
@saenkoandrew 4 жыл бұрын
Hi, very good video! Chris, why u not make Xcode 12 videos ?
@CodeWithChris
@CodeWithChris 4 жыл бұрын
We will in the future! :) - Kat
@thedude1050
@thedude1050 4 жыл бұрын
hey Chris please also make a video on fetching data .
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, you can add your tutorial requests here: cwc.to/request - Kat
@audreyboren7560
@audreyboren7560 4 жыл бұрын
hi chris! i'm currently building an app and thanks to you my journey has been easy. but now i don't know how to convert into an android app. is it possible? if yes, how do i do it?
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello! You can't "convert" an iOS app to Android. You will have to make 2 separate apps if you want both iOS and Android. You'll have to use Swift for iOS and Java to create apps for Android natively. Luckily, there are now many available cross-platform alternatives (like Flutter) that you can use if you don't want to learn both languages. The downside is that it won't give you the same level of control as native apps. - Kat
@karapurakesh
@karapurakesh 4 жыл бұрын
Can you show how to update item using coredata .
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, its in lesson 3 of this series kzbin.info/www/bejne/nYjYo5t8prmmhrc - Francis
@oliebee2005
@oliebee2005 4 жыл бұрын
Hi Chris... great tutorial... Could you show us how to save a group of new objects? using the method that takes nSSet. I'm having trouble converting an array of one CoreData object into an nsSet that can be added as a property to another related Core Date object. Thanks!
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hi! Feel free to post your question in our forum community so that our technical support staff can give you more insights about this. Go here: codecrew.codewithchris.com. Cheers! :-) -Arthur
@nebojsapavlovic2231
@nebojsapavlovic2231 3 жыл бұрын
Could you please show how to add to family dynamically instead of person.name = "Maggy". When I add to my project for example: person.name = person.name than all families have Maggy. Thank you!
@CodeWithChris
@CodeWithChris 3 жыл бұрын
"Hello, that depends on how you want to code your class.. easiest option is to ""hardcode"" the name property to ""Maggy"" in the init() so that everytime you create a family class it always starts with ""Maggy"" as default.. this should be done in your Models instead of CoreData - Francis"
@user-rc2nt1tb2u
@user-rc2nt1tb2u 4 жыл бұрын
Hi chris, I'm working on app that takes personal information from the user ,do i need CoreData ?, or there's another way to save these information?
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, Thuraya! Our technical support staff can help you in our fourm. Post your question here: codecrew.codewithchris.com. All the best!
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, yes you can do that and save it into a database like coredata, or you can go cloud storage using firebase. however if its something basic like just a bit of info maybe you can opt to save it to UserDefaults or Keychain instead - Francis
@sohaibsdq4280
@sohaibsdq4280 3 жыл бұрын
how can we filter our persons based on family names, i tried to create family context object but can not get person from ther.
@CodeWithChris
@CodeWithChris 3 жыл бұрын
"Hello, maybe you are just doing it wrong? you only need an attribute family name or something for your class which you can then use to filter, however make sure that there is a relationship properly established and that there is actually data to be loaded - Francis"
@alex741321
@alex741321 4 жыл бұрын
Hi Chris Thanks for this tutorial, I'm trying to figure out a way of keeping unique words. I have objects stored in core data (like persons in your video), each object has a string attribute (a list of words). Should I use a relationship, to only keep unique words in all the objects together? Example: (Object person A: attribute clothes: red blue) (Object person B: attribute clothes: red black) -> (Object person A: attribute clothes: red blue) (Object person B: attribute clothes: black)
@CodeWithChris
@CodeWithChris 4 жыл бұрын
I am not sure what you mean by "unique words", but from what you seem to be doing you might want to consider reading more into relational databases and how they are linked together its all about how you design your database - Francis
@balakrishnasalla
@balakrishnasalla 2 жыл бұрын
in my project i added 1st entity after that we need some attributes so with out touch 1st entity we add 2nd entity and add two attributes , so my error is 1st entity find out but second entity not find, im beginner how to write coding dont know please suggestions any? please reply as soon as possible. thank you
@CodeWithChris
@CodeWithChris 2 жыл бұрын
Hello, best to post your question in our CodeCrew forum so that our tech support staff can guide you. Go here: codecrew.codewithchris.com. Thanks for learning with us! -Arthur
@daylightkiller2611
@daylightkiller2611 4 жыл бұрын
Please Chris can you make a video for macOS app development
@CodeWithChris
@CodeWithChris 4 жыл бұрын
We're only focusing on iOS app development and kind of moving into more advanced topics so we don't have plans for macOS for now. But who knows in the future. :) - Kat
@amitsarker9768
@amitsarker9768 2 жыл бұрын
Hi Chris, If I delete the family, all the persons class in it will be deleted?
@CodeWithChris
@CodeWithChris 2 жыл бұрын
For technical questions, please post them on our CodeCrew forum. Just visit this link codecrew.codewithchris.com - Pat
@rezwanislam1115
@rezwanislam1115 7 ай бұрын
can we use codable in coredata classes?
@CodeWithChris
@CodeWithChris 7 ай бұрын
Hi, Iñaki here from the CWC team. You may want to check this article out by Donny Wals: www.donnywals.com/using-codable-with-core-data-and-nsmanagedobject/ I remember I implemented something different a few years ago. The idea is that I separated the models for the network layer and the persistence layer. Basically I have two redundant models: one Codable and the other a CoreData entity (and managed object). I parse the JSON response into the codable model, then pass the Codable model into its managed object equivalent which copies the values of the Codable model when I need to persist them. I didn't implemented the managed objects to be Codable directly as they needed a managed object context to exist, which may not be available at the time of encoding/decoding. I created an extension to the managed object subclasses of each entity that accepts the Codable value. Though this is a very simplistic approach as I didn't play enough to deal with relationships and faulting. That's just me sharing some ideas, I hope you get an idea on how to implement yours. Happy coding and thanks for learning with us! - Iñaki
@scottishking9731
@scottishking9731 4 жыл бұрын
Could someone give me some advice please? I have a few app ideas that I would like to make and release, but I don’t know how to make them or release them on the app store. I am not very code savvy, but I am business savvy. Do I have to use an external app coding system to make the app then release it on Xcode? Or can you code the app on that too? I am also not sure on how to test the app and fix bugs. I have tried to learn coding, but not sure which one to learn for coding these apps. I kind of just thought about getting my app ideas coded and released as many different avenues give more potential for money. If anyone could give me any help and advice it would be greatly appreciated. Thanks.
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Xcode is the software you'll use to code the app if you want to publish it on Apple App Store. I would recommend watching this kzbin.info/www/bejne/nZ_ciZWblpedr6M You can vet a developer to build the app for you and just focus on the business side of it, - Kat
@scottishking9731
@scottishking9731 4 жыл бұрын
CodeWithChris ok thanks very much.
@rudolphhock1155
@rudolphhock1155 3 жыл бұрын
Once you learn how to code you will scope your ideas when you realise the work that goes into making them robustly work. First, plan what the goal of your app is, then plan as best you can, and then learn to code in the direction you need (like learning how to store and retrieve data i.e. CoreData) and then make your own app. You'll find that there are many good ideas in the world, but many don't make it because people don't finish them. Good luck !
@scottishking9731
@scottishking9731 3 жыл бұрын
@@rudolphhock1155 thanks for your advice it was helpful. Yeah I have a few different ideas just struggling with them. I’ve since decided to purchase a mac so I’m hoping that will help. Would it be ok if i got back to you to ask any questions? If thats ok. Thanks again.
@rudolphhock1155
@rudolphhock1155 3 жыл бұрын
@@scottishking9731 You mean you were not developing on the macOS platform ? I've never developed on anything but macOS with Swift, but I should imagine that its just a nicer experience. It's code, so it will likely work in any IDE that caters for the language, but Apple does make their environment the nicest to spend a long time in, so it's likely a good investment. Just buy the best you can because Xcode can be resource intensive and I even needed to get a new computer to run the latest (but it was a little old in the tooth), as you know Apple have an aggressive update cycle. I can't answer all your questions, but I don't mind, sure.
@rudolphhock1155
@rudolphhock1155 3 жыл бұрын
Hey Chris proxy, I've got an idea for an app, can you do all the unpaid work for me and then I change my mind near the end, thanks !
@CodeWithChris
@CodeWithChris 3 жыл бұрын
Hello, Rudolph, we don't make apps for others. We only do the education side of things. :-) -Arthur
@nawabhussain4804
@nawabhussain4804 4 жыл бұрын
Hey Chris. I am making a game that rewards a player every 24 hours. And i want to know how i can avoid players cheating by changing the time. Can you make a video og link me something that can help me. Btw i am working with spritekit.
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Hello, best option would be to get the time and date from somewhere else, maybe a website or a server - Francis
@bruhmoment3731
@bruhmoment3731 4 жыл бұрын
I think this is the most difficult part of Core Data. But I think I can kinda understand how it works now
@CodeWithChris
@CodeWithChris 4 жыл бұрын
Yay, progress! Happy for you! :-) -Arthur
@yuvrajagarkar8942
@yuvrajagarkar8942 3 жыл бұрын
gonna try to build a productivity app
@CodeWithChris
@CodeWithChris 3 жыл бұрын
Awesome, can't wait to know how it goes. You got this! -Arthur
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 816 М.
Lamborghini vs Smoke 😱
00:38
Topper Guild
Рет қаралды 48 МЛН
iOS Core Data QuickStart Tutorial 2020
1:10:58
CodeWithChris
Рет қаралды 104 М.
Intro to Databases (MySQL, CloudKit, Firebase, Core Data, Realm)
20:43
Python dataclasses will save you HOURS, also featuring attrs
8:50
The Last Algorithms Course You'll Need by ThePrimeagen | Preview
16:44
Frontend Masters
Рет қаралды 325 М.
Core Data Tutorial - Lesson 1: Core Data Basics
6:47
CodeWithChris
Рет қаралды 65 М.
What is JSON - JSON Parsing in Swift
24:15
CodeWithChris
Рет қаралды 74 М.
CoreData в Swift. Разработка приложений
47:55
simpleDEV. Swift c нуля до бесконечности
Рет қаралды 9 М.