Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    Etsy sells secondhand clothing marketplace Depop to eBay for $1.2B

    February 19, 2026

    Rethinking how quantum phases change – Physics World

    February 19, 2026

    swift – CloudKit records not deleted when removed from iOS app

    February 19, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»swift – CloudKit records not deleted when removed from iOS app
    iOS Development

    swift – CloudKit records not deleted when removed from iOS app

    big tee tech hubBy big tee tech hubFebruary 19, 2026012 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    swift – CloudKit records not deleted when removed from iOS app
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    For an unknown reason, when I delete a record in my app, the CloudKit record does not delete. So the next time the app runs, the “deleted” records come back.

    I add the records as follows:

    func addReadingListBook (book: NYTBook, list: ReadingList) {
        //set it
        var bookToAdd = RLBook(nytBook: book)!
        let parentReference = CKRecord.Reference(recordID: list.recordId!, action: .none)
        bookToAdd.parentReference = parentReference //needed for query
        bookToAdd.record.parent = parentReference //needed for sharing
        myReadingListBooksDictionary[book.primaryIsbn13] = bookToAdd
        
        Task {
            do {
                // Save the RLBook record first
                let savedBookRecord = try await db.save(bookToAdd.record)
                
                // Persist related buy links as child records in CloudKit (if any)
                if let links = book.buyLinks, !links.isEmpty {
                    var buyLinkRecords: [CKRecord] = []
                    for link in links {
                        let buyLinkRecordID = CKRecord.ID(zoneID: savedBookRecord.recordID.zoneID)
                        let buyLinkRecord = CKRecord(recordType: "BuyLink", recordID: buyLinkRecordID)
                        buyLinkRecord["parentReference"] = CKRecord.Reference(recordID: savedBookRecord.recordID, action: .deleteSelf)
                        buyLinkRecord["bookIsbn13"] = book.primaryIsbn13
                        buyLinkRecord["name"] = link.name
                        buyLinkRecord["url"] = link.url
                        buyLinkRecords.append(buyLinkRecord)
                    }
                    if !buyLinkRecords.isEmpty {
                        _ = try await db.modifyRecords(saving: buyLinkRecords, deleting: [])
                    }
                }
            } catch {
                Logger.errorLog.error("\(error.localizedDescription)")
            }
        }
    }
    

    I delete the record like this:

    func removeReadingListBook (book: RLBook) {
        myReadingListBooksDictionary.removeValue (forKey: book.primaryIsbn13)
        Task {
            do {
                // Delete related BuyLink records for this book
                let parentRef = CKRecord.Reference(recordID: book.record.recordID, action: .deleteSelf)
                let linkPredicate = NSPredicate(format: "parentReference == %@", parentRef)
                let linkQuery = CKQuery(recordType: "BuyLink", predicate: linkPredicate)
                let linkResult = try await db.records(matching: linkQuery, inZoneWith: book.record.recordID.zoneID)
                let linkRecordIDs: [CKRecord.ID] = linkResult.matchResults.compactMap { try? $0.1.get().recordID }
                if !linkRecordIDs.isEmpty {
                    _ = try await db.modifyRecords(saving: [], deleting: linkRecordIDs)
                }
                
                // Now delete the book record itself
                try await db.deleteRecord(withID: book.record.recordID)
                
            } catch {
                Logger.errorLog.error("\(error.localizedDescription)")
            }
        }
    }
    

    I have checked role permissions and everything else I can think of or find on the internet. Any help would be appreciated.



    Source link

    app CloudKit deleted iOS Records removed Swift
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    ios – Inexplicable white background below SwiftUI Webview

    February 18, 2026

    Setting up a delivery pipeline for your agentic iOS projects – Donny Wals

    February 17, 2026

    ios – Verbose Swift code, looking for advice on simplifying and improving

    February 16, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    Etsy sells secondhand clothing marketplace Depop to eBay for $1.2B

    February 19, 2026

    Rethinking how quantum phases change – Physics World

    February 19, 2026

    swift – CloudKit records not deleted when removed from iOS app

    February 19, 2026

    How the ability to Buy, Bring or Blend profiles is reshaping IoT connectivity

    February 18, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    Etsy sells secondhand clothing marketplace Depop to eBay for $1.2B

    February 19, 2026

    Rethinking how quantum phases change – Physics World

    February 19, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.