Core data CRUD using repository pattern in swift Hindi tutorial Part 1

Поделиться
HTML-код
  • Опубликовано: 20 окт 2024

Комментарии • 95

  • @CodeCat15
    @CodeCat15  4 года назад +5

    Working with the local storage can be a little overwhelming if you are not following the right design pattern be it core data or any third party tool, in this tutorial I explain the following topics
    1. Why singleton approach is not good for local storage along with technical reasons
    2. Introduction to repository pattern
    3. How to avoid breaking abstraction
    4. Some fun with Generics in the persistent Storage class
    And some of my examples as usual
    This is the first part and the second part will be out this week, am not going to keep you waiting for an entire week for this. Please do like this video and do subscribe to the channel and share it with your iOS group

    • @thesidkhanna
      @thesidkhanna 3 года назад +1

      Great video
      Just one suggestion
      Instead of using forEach loop to convert cdEmployee to employee, you can use map function

  • @iosappmakers7499
    @iosappmakers7499 3 года назад

    Generally, I don't comment on videos, but today taking time to comment. because it is worth watching and thumbs up. No words to say. Actually, I am an iOS Trainer but I learned something new from you.
    Thanks

  • @madmaxcoder6209
    @madmaxcoder6209 4 года назад +1

    This is premium quality content for which people pay and watch and you are just giving it for free and explaining in very simple term. Thank you for sharing this Ravi.

  • @AnuragKashyap17
    @AnuragKashyap17 4 года назад +2

    Bro, I am really thankful that you are here to help developers like me , whenever you say “Creative Developer” I tend to creat a creative image of mine in my mind 😅 where I see myself doing creative things 😐

    • @CodeCat15
      @CodeCat15  4 года назад +1

      You see today your code may not be that good and don’t feel bad about it, practice it, always think before you code, read more on solid principles. Am sure you will write code 100 times better than me.
      It took me time to practice, implement, think like this and it was a bumpy ride of trial and errors.
      There’s a story behind how i started to code like this or whats my journey in programming i will share it someday on my channel

    • @AnuragKashyap17
      @AnuragKashyap17 4 года назад +1

      Code Cat I will be waiting for that , I am sure it will definitely help me , you lectures are so amazing that when the tutorial completes I actually say to myself arey khatam why it’s not more 😅 I literally get so engaged with the content ❤️❤️❤️

    • @CodeCat15
      @CodeCat15  4 года назад +1

      @@AnuragKashyap17 Second part iska mai Wednesday tak release karne ka try karta hu and those are kind words thanks man it means a lot to me. I think ye 1000 subscriber special video banata hu mai.

    • @AnuragKashyap17
      @AnuragKashyap17 4 года назад +1

      Code Cat Arey wahhh!!!! Congratulations in advance ❤️❤️❤️ You deserve a ton of subscribers bro 🤘🏽

    • @CodeCat15
      @CodeCat15  4 года назад +1

      Thanks yaar, socha nahi tha aisa kabhi hoga coz maine assume kiya tha ki 200 ya 150 hoga but I will surely share a thank you video and my journey in programming.

  • @vimobee
    @vimobee 4 года назад +2

    Thanx Ravi, I wish I could give you more likes for the video 😊. Loved the way you organised the code. The channel deserves more subscribers for the quality of contents you are providing. Looking forward for next video of the series. 👍

    • @CodeCat15
      @CodeCat15  4 года назад

      Thanks Vikas that’s really nice of you to say such kind words. Please feel free to ask questions on this topic and share this channel with your iOS group.

    • @vimobee
      @vimobee 4 года назад +1

      ​@@CodeCat15 Could you please explain id as CVarArg part of the predicate. When should we caste any property as CVarArg ?

    • @CodeCat15
      @CodeCat15  4 года назад

      Sorry @Vikas I could not get back to you, I am not getting notifications for the comments so i manually check. So coming to your question if the parameter was a string or int then the conversion was not required but in the case of UUID since UUID does not conform the protocol CVarArg the manual conversion was needed. so when I did "Id as CVarArg" I am converting the UUID to a va_list which is variable argument list in C programming. Let me know if that answers your question and once again apologies for not getting back in time.

  • @techi-vintechnologies7573
    @techi-vintechnologies7573 4 года назад +1

    Hi Ravi Sir, This is Vinod Mahale. (iPhone batch no 17, Quagnatia..) Glad to see you here. Got your channel link from Arjun...

    • @CodeCat15
      @CodeCat15  4 года назад

      Hey Vinod long time no see, yes i did share my channel yesterday with Arjun, hope it helps you in understanding the core concepts of swift and thank you for your kind words. Do share it with other members as well and do ask them to subscribe

    • @techi-vintechnologies7573
      @techi-vintechnologies7573 4 года назад +1

      @@CodeCat15 Sure sir

  • @sharmiv1060
    @sharmiv1060 3 года назад +1

    hiii ravi .... i am became ur fan..... u r too too gud.... u r talking both in hindi and english inbetween thats y I understand Language is the problem for me . I dont know hindi. Its my kind request for you to do explain in English.. It will be very helpful for many...

    • @CodeCat15
      @CodeCat15  3 года назад +2

      Hey Sharmi, I would like to apologize if language has caused you issues in understanding the topic, I will be very much happy to answer your queries on this topic so please do feel free to ask questions.
      I think it's almost time to have a poll on this, you see I would be happy to make a video in English but mostly the viewers prefer hindi, but from time to time I keep on doing a temperature check to ask my viewers what they want and soon I will add a poll for this on my instagram handle :)

    • @sharmiv1060
      @sharmiv1060 3 года назад +1

      @@CodeCat15 k bro ...

  • @MandeepSingh-ly3jj
    @MandeepSingh-ly3jj 4 года назад +1

    I really like background music and motivation thought on wallpaper . I learn so many thing from this video. very simple and easy to understand . I think you are big fan of Einstein.

    • @CodeCat15
      @CodeCat15  4 года назад +2

      Thanks a lot for the comment, I am just a curious person who wants to explore and have fun with technology so I keep on moving from one technology do couple of projects in that and then move to the next one.
      My Dad, Einstein, Nikola Tesla, Bruce Lee and Steve Jobs are my greatest inspirations of all time. Writing clean code is very easy and that's all I want to show from this channel.

    • @MandeepSingh-ly3jj
      @MandeepSingh-ly3jj 4 года назад +1

      @@CodeCat15 Sir you follow these genius and programming and I follow your your RUclips it will clear my all concept surely due to explanation in simple and clear with real life example . In IT world specially in India Nobody guide to junior developer properly they think if they guide to junior and if junior achieve excellence and then their job or position will be in bad situation , means they used politics agenda in company

    • @MandeepSingh-ly3jj
      @MandeepSingh-ly3jj 4 года назад

      @@CodeCat15 With the help of your channel lots of junior or mid level developer will be understand what the things is going on in iOS and difference between quality code and unwanted and hard to manage code.

    • @CodeCat15
      @CodeCat15  4 года назад +2

      Nobody guided me too so I know the pain and I know what you might be going through, I am not saying its an easy path but all we should focus on is improving our self as a programmer.
      Not all seniors are like that some are very kind and try to help the junior devs as much as they can but its very unfortunate that you have to come across such creative seniors. I think if we just do our job and make sure we cover all the use cases then people no matter how bad they play politics won't be successful as our work speaks for itself.
      This is my advice to you, just focus on your work, make sure all the use cases are covered, my channel is very new so i may take time to cover some topics but ultimately I will cover them with easy examples.

    • @MandeepSingh-ly3jj
      @MandeepSingh-ly3jj 4 года назад +1

      @@CodeCat15 Sir, Thanks for your advice

  • @dipeshmakvana7324
    @dipeshmakvana7324 3 года назад +1

    Hi, In EmployeeDataRepository swift file in protocol Employee comes from where??

  • @AnuragKashyap17
    @AnuragKashyap17 4 года назад +1

    Bro, Please do try to explain dependence inversion in this topic as well. I know you have already explained and there is video out there for this but please do explain the same here as well, like fetching the data from the api and then storing it to the database for which we will be having different class for Core data handling and API handling so I guess in that case Dependency Inversion can be demonstrated again, please correct me if I am wrong. That will actually be a real life scenario when coding. And will actually give a more clearer vision on both these topics.

    • @CodeCat15
      @CodeCat15  4 года назад +2

      the dependency inversion principles states that the high level modules do not depend on low level modules, so in this example, if you observe I have a protocol in the repository so all I am saying is yes it is one of my topics for the core data playlist I already thought about this because this scenario has its own complexity which we need to dealth with because you will have two repositories here APIRepository to fetch data from the server for employee and a database repository for local storage and fun fact APIRepository cannot and should not call DatabaseRepository because then you introduce coupling between them, will I use DI or something better let's find out when I release that topic.

    • @AnuragKashyap17
      @AnuragKashyap17 4 года назад +1

      Code Cat cool enough 🤘🏽🤘🏽🤘🏽

  • @rahulkatore5563
    @rahulkatore5563 2 года назад

    Thank you!, why you have not added this operations in earlier CoreDataDemo Project??, that will be very helpful to understand.

  • @shahbaze63
    @shahbaze63 4 года назад +1

    Thank you so much for this..

    • @CodeCat15
      @CodeCat15  4 года назад

      Am glad this was helpful @Shahbaz. Please feel free to ask questions on this topic will be happy to answer them

  • @goutamdas641
    @goutamdas641 2 года назад +1

    Thank you. At time 15:11 what shortcut you used at line 41?

    • @CodeCat15
      @CodeCat15  2 года назад

      its not a short cut but default suggestion from xcode itself I just pressed enter that's all

    • @goutamdas641
      @goutamdas641 2 года назад

      @@CodeCat15 Okay 👍

  • @lordironman2874
    @lordironman2874 3 года назад

    Sir, ye core data ke Operations kis thread pr hote hain (main or background) if we do not specify any explicitly ?

  • @smackbot7656
    @smackbot7656 2 года назад

    Hi Ravi. Can you make a video on how to make a boilerplate for core data such that I can directly download the files and include them in my code? More like a boilerplate instead of "Employee", or "CDEmployee" entity, we can take any entity that our project contains. (Using Generics)

  • @vashusaini021
    @vashusaini021 4 года назад +1

    good one brother

    • @CodeCat15
      @CodeCat15  4 года назад +1

      Welcome to the channel Vashu, am glad this video was helpful. Please feel free to ask questions on this topic and so share it with your iOS group 😊

  • @prachibile2798
    @prachibile2798 Месяц назад +1

    I want to know how to fetch records with multiple parameters, like fetch employee data based on empID, empSalary, empDpt, etc.?

    • @CodeCat15
      @CodeCat15  Месяц назад

      By using NSCompoundPredicate

  • @Xunnun
    @Xunnun Год назад +1

    Sir. I'm facing a problem on 18:40
    let predicate = NSPredicate(format: "id==%@", id as CVarArg)
    the like show me this error "Cannot convert value of type '(any AnyObject).Type' (aka '(any AnyObject).Type') to type 'any CVarArg' in coercion | Insert ' as! any CVarArg'

    • @CodeCat15
      @CodeCat15  Год назад

      if you do the force unwrapping then does it work?

  • @AhsanZahidDevb
    @AhsanZahidDevb 4 года назад +1

    BEST ONE 👍🏻

    • @CodeCat15
      @CodeCat15  4 года назад +1

      Hey Ahsan, welcome to the channel thanks a lot for your comment, please feel free to ask questions on this topic will be happy to answer them and do share this with your iOS group on WhatsApp or Facebook

    • @AhsanZahidDevb
      @AhsanZahidDevb 4 года назад +1

      Sure

  • @Rasikabharati21
    @Rasikabharati21 3 года назад

    very helpful!

  • @ProductsHub365
    @ProductsHub365 3 года назад +1

    from where did u get this persistantstorage object can we handle persistant storage object in base data repository globally ?

    • @CodeCat15
      @CodeCat15  3 года назад

      In the first part of core data I am explaining why I created this singleton class and what was the though process behind it. Do check the introduction to core data video given below is the link for the same
      Link: ruclips.net/video/wAy3S1MnKYY/видео.html

  • @Shade_with_me_7
    @Shade_with_me_7 3 года назад +1

    Hi, Can you make one video for which store data from API response with the relationship if possible?

    • @CodeCat15
      @CodeCat15  3 года назад +1

      I am going to, actually there are 2 maybe 3 videos which I want to explore with core data and the topic you requested Dipak is one of them.

  • @HirenMistry0125
    @HirenMistry0125 4 года назад +1

    Hello,
    i have save four textfiled data, but when i fetch and show on tableview it shows only one entry (last textfield data), any suggetion?

    • @CodeCat15
      @CodeCat15  4 года назад +1

      Seems like a data binding issues, make sure all those values are set to the attribute of the entity.

  • @suryakantsharma6761
    @suryakantsharma6761 3 года назад

    ye CVArg kya hia ? Please explain these things while creating the videos thansk

  • @sumitrathore8446
    @sumitrathore8446 3 года назад +1

    Can we use higher order function for filter ?

    • @CodeCat15
      @CodeCat15  3 года назад

      Yes you can at it works well too :)

  • @niteshvishwakarma690
    @niteshvishwakarma690 3 года назад +1

    We really have a similar mind Code Cat.

    • @CodeCat15
      @CodeCat15  3 года назад

      Are you my twin brother Nitesh hahaha cheers 🍻

  • @gowthamravi7353
    @gowthamravi7353 7 месяцев назад +1

    Hi Sir. Why do we need convertToEmployee method when the data we are getting from fetchManagedObjects method is already an array of the type we declared?
    func getAll() -> [Employee] {
    guard let employees = PersistentStorage.shared.fetchManagedObject(managedObject: Employee.self) else { return [] }
    return employees
    }
    Is this code not enough on getAll method?

    • @CodeCat15
      @CodeCat15  4 месяца назад

      You could do that but then it will expose the domain model to the client layer which is not advisable because the client might not need all of those OR before passing to the client there could be certain data-formatting that you may need to do like formatting the date based on the user's locale OR formatting a string to remove special character and hence you should always maintain a separation between domain and the client data model

  • @imhrithik1713
    @imhrithik1713 Год назад

    Good

  • @paonej4033
    @paonej4033 Год назад +1

    Without going for repository pattern why can't we use generic singleton class for CRUD operations

    • @CodeCat15
      @CodeCat15  Год назад

      Here are the drawbacks of using a generic singleton class for CRUD operations
      1. Lack of separation of concern: Generic singletons mix data access logic with application logic, violating the principle of separation of concerns and making code harder to maintain.
      2. Testing Challenges: Tight coupling to data sources in a singleton makes unit testing difficult, as you can't easily substitute mock data for testing purposes.
      3. Limited Adaptability: Generic singletons lack the flexibility needed to adapt to changing data access requirements, potentially causing difficulties when switching data sources or optimizing data access.
      4. Scalability Challenges: As your codebase becomes more complex and your data access needs become more specialized, maintaining a single monolithic class for all CRUD operations can become unwieldy. The repository pattern allows you to create specialized repositories for different entities or data types, promoting a more scalable and maintainable architecture.
      while using a generic singleton class for CRUD operations may seem like a straightforward solution initially, it can lead to several drawbacks, including poor separation of concerns, reduced testability, limited flexibility, and scalability challenges.

    • @paonej4033
      @paonej4033 Год назад +1

      @@CodeCat15 Thanks ravi for the sharing disadvantages of using generic singleton pattern

    • @CodeCat15
      @CodeCat15  Год назад

      Glad it was helpful, please feel free to ask more questions

  • @Cricketingshorts786
    @Cricketingshorts786 4 года назад +1

    can u please tell me when u will upload next part of the video

    • @CodeCat15
      @CodeCat15  4 года назад +1

      Will be done in this week mostly by Wednesday, let me know if you have any questions on this and please do share this with your iOS group

    • @Cricketingshorts786
      @Cricketingshorts786 4 года назад

      @@CodeCat15 hey waiting for video

  • @kaberidas6109
    @kaberidas6109 2 года назад +1

    Why do we declare singjeton class as final??

    • @CodeCat15
      @CodeCat15  2 года назад

      We don’t want that class to be inherited by other class and hence to make sure that does not happen we mark it as final
      If not then someone will get an idea of subclassing it and now you have two classes with same behavior manipulating the core data store that’s violation of single responsibility principle

  • @saqibrehman8692
    @saqibrehman8692 4 года назад +1

    sir image ki primitve type kkyya h to .. image variable kaise bnne ga

    • @CodeCat15
      @CodeCat15  4 года назад

      Hello Saqib, welcome to the channel image ko aap as data store kar sakte ho, so you do have data as a type in core data, to using that you can store binary, there are other ways too of doing that maine part 2 mai usse explain kiya hai. Is video mai agar aapko koi doubt ho to please puchna zaroor aur ye channel aapne iOS group mai bhi share karna

  • @thejask2765
    @thejask2765 3 года назад

    Can you show us how to create that Models also? coordination is missing when trying the trial of this tutorial in Xcode .

    • @CodeCat15
      @CodeCat15  3 года назад

      I am assuming you mean the core data models? Steps to create them are shown at 10:04 let me know it that’s what you are looking for

    • @thejask2765
      @thejask2765 3 года назад

      @@CodeCat15 not there. It’s here 15:21. I’ve looked into your GitHub files for that. No problem. 🙂

    • @CodeCat15
      @CodeCat15  3 года назад +1

      Oh okay cool 👍 feel free to ask questions on this and do share with your iOS group if this video was helpful

    • @thejask2765
      @thejask2765 3 года назад

      @@CodeCat15 sure👍

  • @sheshadrivendramishra1543
    @sheshadrivendramishra1543 3 года назад +1

    Sir how to add multiple entities??

    • @CodeCat15
      @CodeCat15  3 года назад +1

      Multiple entities as in from an API?

    • @sheshadrivendramishra1543
      @sheshadrivendramishra1543 3 года назад

      @@CodeCat15 no no sir, you know we can create multiple entities and can make relationship between these entities

    • @CodeCat15
      @CodeCat15  3 года назад +1

      You need to have the entities defined in the xcdata model with their relationships and then you can just inject data as shown in the demo. Whatever the case you need to have all your entities with their relationships defined in the model before you write the code, if you try to do things dynamically then it may cause issues or worst versioning can be a pain to deal with. Let me know if that answers your question and if not send me an email with a sample codebase of what you are trying to accomplish with what have you tried so far

    • @sheshadrivendramishra1543
      @sheshadrivendramishra1543 3 года назад +1

      @@CodeCat15 ok sir..sure

  • @hareeshgangadhara415
    @hareeshgangadhara415 4 года назад +1

    Employee comes from where

    • @CodeCat15
      @CodeCat15  4 года назад

      The employee record will be coming from the UI. User will enter the record and it will be saved using core data, did I answer your question? If not then please feel free to ask I will be happy to answer them.
      Also there's a part 2 of this video I recommend seeing that as well

    • @smackbot7656
      @smackbot7656 2 года назад

      @@CodeCat15 Have you made any struct named Employee cause the NSManagedObject is CDEmployee right and in the protocol you are declaring Employee. Thats what he is asking. Whether we have to make a struct which has same as CDEmployee

  • @iSubhoo
    @iSubhoo 4 месяца назад +1

    Too much Complicated Video, also at 18:30 why using NSPredicate, what is it? why using format: "id==%@" nothing emplained. Just coding is going on.

    • @CodeCat15
      @CodeCat15  4 месяца назад

      Sorry if you feel that way, NSPredicate is a class that works like a filter in core data it's similar to a WHERE clause in SQL, hope that helps.

  • @itscrypto-techtime89
    @itscrypto-techtime89 Год назад +1

    It's incomplete video.

    • @CodeCat15
      @CodeCat15  Год назад

      Checkout the core data playlist you’ll find the second part there.