Converting a Core Data Entity to a CKRecord for sharing using the UICloudSharingController with Seam3

301 Views Asked by At

When trying to instantiate a CKRecord from my current datastore, I am unable to initialize it using Seam3. The core data stack and CloudKit are in perfect sync thanks to Seam3. I'm bulding a wishlist application that enables list sharing and I'm trying to implement this feature. Without a CKRecord to send to UICloudSharingController, I can't finish this feature.

I have tried converting to a CKRecord by hand and I don't know what I'm doing wrong.

func loadData() {
        let fetchRequest = NSFetchRequest<List>(entityName: "List")
        let sortDescriptor = NSSortDescriptor(key: "title", ascending: true)
        fetchRequest.sortDescriptors = [sortDescriptor]
        if let result = try? dataController.viewContext.fetch(fetchRequest) {
            lists = result
            tableView.reloadData()
        }
    }
override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        loadData()
        NotificationCenter.default.addObserver(forName: Notification.Name(rawValue: SMStoreNotification.SyncDidFinish), object: nil, queue: nil) { [weak self] notification in
            if notification.userInfo != nil {
                self?.dataController.smStore?.triggerSync(complete: true)
            }
            self?.dataController.viewContext.refreshAllObjects()
            DispatchQueue.main.async {
                self?.loadData()
            }
        }
    }

These are the ways I am populating the tableView. I'm not sure how Seam3 works in the background to populate with the CloudKit Items. But its a seamless bridging between CloudKit and CoreData. Any help would be appreciated.... Thanks!

0

There are 0 best solutions below