Tags down


CloudKit Sync using NSPersistentCloudKitContainer in iOS13

By : 常贺贺
Date : October 01 2020, 02:00 AM
help you fix your problem Frustratingly, I think this is 'normal' behaviour, particularly with a large database with a large number of relationships to sync - there is no way to see the progress (to show the user) nor can you speed it up.
NSPersistentCloudKitContainer seems to treat each relationship as an individual CKRecord, with syncing still bound by the same limitations (ie. no more than 400 'requests' at a time), you'll often see these .limitExceeded errors in the Console, but with little other information (ie. if/when will it retry??).
code :
static var useCloudSync = UserDefaults.standard.bool(forKey: "useCloudSync")
static var persistentContainer:  NSPersistentContainer  = {
    let container: NSPersistentContainer?
    if useCloudSync {
        container = NSPersistentCloudKitContainer(name: "MyApp")
    } else {
        container = NSPersistentContainer(name: "MyApp")
        let description = container!.persistentStoreDescriptions.first
        description?.setOption(true as NSNumber,
                               forKey: NSPersistentHistoryTrackingKey)

    container!.loadPersistentStores(completionHandler: { (storeDescription, error) in
    if let error = error as NSError? {
        fatalError("Unresolved error \(error), \(error.userInfo)")
    return container!

Share : facebook icon twitter icon

CloudKit: Using notifications to keep changes in sync across multiple devices

By : Ivo
Date : March 29 2020, 07:55 AM
it should still fix some issue The server will delete the old notifications, regardless of the read status.

CloudKit sync testing with sandbox users

By : Chang Xu
Date : March 29 2020, 07:55 AM
wish helps you Question 1: Using the App Receipt to restore non-renewable subscriptions
From Apple's Documentation:
code :
Subscription type       Auto-renewable   Non-renewing    Free
Users can buy           Multiple times   Multiple times  Once
Appears in the receipt  Always           Always          Always
Synced across devices   By the system    By your app     By the system
Restored                By the system    By your app     By the system

CloudKit Offline Sync

By : Chris Johnson
Date : March 29 2020, 07:55 AM
Hope that helps In order to work with CloudKit you must be online. Being offline returns a CKError detailed and Internet Connecction error.
fetchAllLongLivedOperationIDs only returns the operations IDs that are running or had finished in a short period of time.

IOS13+ NSPersistentCloudKitContainer UIRefreshControl how to refresh UITableView content

By : user261130
Date : March 29 2020, 07:55 AM
hope this fix your issue Using NSFetchedResultsController will keep your table in sync with the CoreData database automatically. In the code below, you'll have to replace instances of YourEntityName with the real database entity name that you're using in your project.
You might also want to set request.sortDescriptors appropriately. For example, if you are using a search bar you could include the search bar text in the sort descriptors, and then you'd have to call the method updateFetchedResultsController() each time the search bar text changes.
code :
import UIKit
import CoreData

class YourTableViewController: UITableViewController, NSFetchedResultsControllerDelegate {

    var container: NSPersistentContainer? = (UIApplication.shared.delegate as? AppDelegate)?.persistentContainer

    var fetchedResultsController: NSFetchedResultsController<YourEntityName>? {
        didSet {
            fetchedResultsController?.delegate = self

    override func viewDidLoad() {

    func updateFetchedResultsController() {
        guard let context = container?.viewContext else {

        context.performAndWait {
            let request: NSFetchRequest<YourEntityName> = YourEntityName.fetchRequest()
            request.sortDescriptors = nil // set sort descriptors if you want data ordered specifically
            request.predicate = nil // set predicate if you only want specific data

            fetchedResultsController = NSFetchedResultsController<YourEntityName>(
                fetchRequest: request,
                managedObjectContext: context,
                sectionNameKeyPath: nil,
                cacheName: nil

            do {
                try fetchedResultsController!.performFetch()
            } catch {
                // Handle the error, for example, present an alert

    // MARK:- UITableViewDataSource

    override func numberOfSections(in tableView: UITableView) -> Int {
        return fetchedResultsController?.sections?.count ?? 0

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if let sections = fetchedResultsController?.sections, sections.count > 0 {
            return sections[section].numberOfObjects
        return 0

    override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        if let sections = fetchedResultsController?.sections, sections.count > 0 {
            return sections[section].name
        return nil

    override func sectionIndexTitles(for tableView: UITableView) -> [String]? {
        return fetchedResultsController?.sectionIndexTitles

    override func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
        return fetchedResultsController?.section(forSectionIndexTitle: title, at: index) ?? 0

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "YourCellIdentifier", for: indexPath) as! YourTableViewCell        
        let object = fetchedResultsController?.object(at: indexPath)
        // use data in object to update your cell
        return cell

    // MARK:- NSFetchedResultsControllerDelegate

    func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {

    func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange sectionInfo: NSFetchedResultsSectionInfo, atSectionIndex sectionIndex: Int, for type: NSFetchedResultsChangeType) {
        switch type {
        case .insert: tableView.insertSections([sectionIndex], with: .fade)
        case .delete: tableView.deleteSections([sectionIndex], with: .fade)
        default: break

    func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
        switch type {
        case .insert:
            tableView.insertRows(at: [newIndexPath!], with: .fade)
        case .delete:
            tableView.deleteRows(at: [indexPath!], with: .fade)
        case .update:
            tableView.reloadRows(at: [indexPath!], with: .fade)
        case .move:
            tableView.deleteRows(at: [indexPath!], with: .fade)
            tableView.insertRows(at: [newIndexPath!], with: .fade)

    func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
lazy var persistentContainer: NSPersistentCloudKitContainer = {

    let container = NSPersistentCloudKitContainer(name: "YourEntityName")

    container.loadPersistentStores { description, error in
        if let error = error {
            // handle the error

    container.viewContext.automaticallyMergesChangesFromParent = true
    return container

How to sync records between Core Data and CloudKit efficiently

By : Shwar Randive
Date : March 29 2020, 07:55 AM
hop of those help? Core Data already provides the user with the ability to sync to iCloud. There's no need to use CloudKit.
Design For Core Data In iCloud
Related Posts Related Posts :
  • How to monitor windows manchine in grafana using prometheus?
  • Produce new word2vec model from existing one
  • Migrating Rails from Asset Pipeline to Webpacker: Uncaught ReferenceError: $ is not defined in rails-ujs.js
  • Extract lines with string and variable number pattern
  • Configuration priority - best practise
  • WebAssembly dynamic module unloading
  • Call SWS Via Sabre Red Workspace From Native API Bridge Application
  • How to set query timeout when using Presto CLI?
  • What's the difference between agent.add() and conv.ask() on dialogflow
  • Pymodbus - Read input register of Energy meter over rs485 on uart of raspberry pi3
  • Execute bash script on a dataproc cluster from a composer
  • Gremlin: select vertex based on comparison of two property values
  • How do you createRef in Suave Fable?
  • I am having trouble building Azerothcore on Windows 10 Home, VS 2017
  • Why is testcafe-docker.sh ignoring app-init-delay parameter?
  • DynamoDB Adjacency List Pattern
  • Is there a way for my aplication to detect beacons in Powerapps?
  • "Initialize interactive with Project" is missing for .Net Core Projects in Visual Studio 2019
  • Cosmos db Order by on 'computed field'
  • let a rpm to automatically install centos-release-scl-rh
  • What is the "Stage" folder inside MarkLogic Installed Directory? How does MarkLogic use this folder?
  • Implement requestHooks in cucumber/testCafe
  • Jhipster: How can I only generate a back-end microservice application
  • Building a database of average speed from two cameras using cloudant entries
  • Move file from inbound adapter after publish subscribe flow
  • Is there enough of a difference between WebSphere 8.5.5 on Linux vs Windows to warrant testing our application in WebSph
  • Wait some seconds before agent's reply
  • Is there a Apache Beam + Cloud Bigtable connector in Golang?
  • How I can convert ampl file to cplex?
  • Is there a description of the mecab (Japanese word parser) algorithm?
  • CALL SYMPUT a character operand was found in the %EVAL function
  • Problem 1 Write the PRETTY-PRINT procedure, which takes one argument (a generalized list), and prints it using the follo
  • How to get the merchant, where a NFC-enabled pass is used?
  • Determine RFC caller?
  • Does appium-dotnet-driver support .net core 2.x?
  • Error:Internal error: (java.lang.ClassNotFoundException) com.google.wireless.android.sdk.stats.IntellijIndexingStats$Ind
  • RxJS do not throw error while mapping even when underlying observable throws error
  • What is the difference between last and publishLast operator in rxJS?
  • Displaying Select Box from enum data
  • How to disable and hide the pagination footer for react-table?
  • Airflow 1.10.3 SubDag can only run 1 task in parallel even the concurrency is 8
  • Red Hat Fuse ESB Community vs Enterprise edition
  • Map subtask_id to TaskManager in Flink
  • Why do we need semaphores on single cpu?
  • appRole defined in AzureAD application not being included for guest user of type "External Azure Active Directory&q
  • Angular material mat menu styling issue
  • OctoberCMS from input to databse
  • cloud function with pub sub trigger does not work across regions
  • Eventlistener for paper-dropdown-menu in Lit-html
  • Combining the elements of array and reformatting the output
  • How do i generate Agent Credentials for Bosch IoT Permissions?
  • Unable to interact with the ledger (invoke and query only happening on world state (couchdb))
  • Kentico 12 MVC - Customize BizForm response
  • AutoHotkey: list all open windows
  • Docompose tag by its content/text
  • Make concat_lines_of( ) work for rawstring
  • Naming steps as Tasks vs Statuses in Process Design
  • Why is a true value rendered as "value"?
  • JSON Validate check based on response from arrayElement
  • Is it posible to have multiple grapesjs instances on the same page?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk