Share CoreData with Widget Extension

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

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

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

    Thank you. This video is very helpful.

  • @이건우-z2n
    @이건우-z2n 9 месяцев назад +1

    thank you
    from South Korea

  • @OmarElsayed-r8g
    @OmarElsayed-r8g 11 месяцев назад +1

    thank you for this amazing video

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

    Great video Flo! Thanks for sharing 🙌

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

      My pleasure! I struggled a lot with this when I first started looking into it, so I thought a video would go a long way for newer developers :)

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

    thanks a lot! you save my day!

  • @OmarElsayed-r8g
    @OmarElsayed-r8g 9 месяцев назад +1

    this works perfectly with normal coreData, but what if I used CoreData with cloud kit. now how can I make the widget access the data

  • @rideroliver
    @rideroliver Год назад +2

    Hey any hints on how to set that container to work with cloud kit? I’ve been previously just been changing the container type to nscloudkitcontainer and letting it do the rest but doing this seams to have stopped that. Many thanks in advance, great vid btw very clear

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

      Interesting, adding CloudKit support should work the same with and without App Groups. Is your CoreData model shared with the Widget and set to "Used with CloudKit"? Does your Widget have the capabilities that are needed for CloudKit?

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

      @@FloWritesCode I "think" the problem is you need to have multiple containers or contexts. I ran into the problem as well.

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

    Thank you!! :)

  • @王嘉问
    @王嘉问 Год назад +1

    if i use icloud, did i just use your way and use NSPersistentCloudKitContainer Instead of NSPersistentContainer?

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

      Yes, that's the very basic setup. You might want to have a look at the configurations as well :)

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

    AMAZING !!!

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

    With regards to migrating an existing project to app groups, you mentioned the need to manually migrate the data within the databases. Is it not possible to move the sqlite file as a whole to the new location?
    A sort of `FileManager.default.moveItem(at: oldLocation, to: newLocation)` situation? Might be nice to dive into this a bit more!
    Definitely learnt about generating app group URLs! Only used them in the context of UserDefaults before - neato.

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

      Thanks! Yeah, I think that is how I would do it as well. I have only heard from others about migrating CoreData stores though - never had to do it myself fortunately. If I come across having to do this myself I will make a video about it for sure :)

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

    Hello, Thanks for sharing great video.😃
    I have one question, Can we do vice versa like store the data in "core data" and acess that data in main app.
    I have tried that but always getting blank values .
    Thanks.

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

      Where in the widget did you try to store things in CoreData? AFAIK the only place that works is in the TimelineProvider (or in AppIntents with iOS 17's interactive widgets).

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

      @@FloWritesCode I am working on Messagefilter Extention. and i get some data in that extention via system. I want to Store that data in "core data" and display on Main UI.

  • @GabrielLeal-c7h
    @GabrielLeal-c7h 10 месяцев назад

    What if my core data implementation is on an external SDK, imported by main app? For example, I got an Token SDK imported by the main app, this sdk stores the tokens on core data and I need to access them on my app extension

    • @FloWritesCode
      @FloWritesCode  10 месяцев назад

      Are you able to fork the SDK and change the CoreData implementation in there?

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

    How to share data with the macos widget, because the main app and macOS widget require different prefixes

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

      The iOS prefix "group." is just a suggestion. You can remove it from the TextField and replace it with whatever you'd like.

  •  Год назад +1

    Is CoreData is 👍

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

    there is an issue I am using iCloud for syncing the data and if I use App Group the iCloud does not work for me my code is the same as yours in different that I am using NSPersistentCloudKitContainer

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

      Facing the same issue, someone on the internet told me to set storedescription.cloudKitContainerOptions to nil. Lemme know if you find another solution

    • @王嘉问
      @王嘉问 Год назад

      hi did you fix this problem?thx

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

      @@王嘉问 yes you will need to set the cloud kit container options in the if let which get the url with the iCloud identifier

  • @yuniorsanchez8578
    @yuniorsanchez8578 9 месяцев назад

    It will be a good idea to make a simple app where you can save to firebase if there is internet and to coredata if no internet to persist the data on the device, and then be able to have a widget that follow the same and pull the count of items in the array following the same logic

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

    What is the Item?

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

      It's the default entity from CoreData.

  • @daniladergachev
    @daniladergachev 8 месяцев назад

    Video should've started with "if you already have coredata without an app group, you will need to migrate the data".. not risking it... I already tried migrating from one version of coredata store to another, and it was one synced with icloud, and users who didn't have enough storage space in iCloud just lost all their data...

  • @AyushiDadarwala
    @AyushiDadarwala 6 месяцев назад

    You actually didn't show how to use this in the widget files.

  • @arnosolo2008
    @arnosolo2008 11 месяцев назад +1

    Thank you. This video is very helpful.