Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
256 views
in Technique[技术] by (71.8m points)

SwiftUI automatic refresh of CloudKit data

I'm using CloudKit to store my data but now I have to close the app every time something changed. With @FetchRequest this should be automatic, shouldn't it?

@FetchRequest(
    sortDescriptors: [NSSortDescriptor(keyPath: Exercise.createdAt, ascending: true)],
    animation: .default)

private var exercises: FetchedResults<Exercise>
question from:https://stackoverflow.com/questions/65844964/swiftui-automatic-refresh-of-cloudkit-data

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Make sure your have enabled Push and remote notifications per the Apple Documentation

Project Settings > Signing and Capabilities 

Sync CoreData with CloudKit using

try? persistentContainer.viewContext.setQueryGenerationFrom(.current)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...