Hi all,
I'm testing the first beta for iOS 16.4 and Xcode 14.3 and I'm getting these warnings that I kind of understand, but I don't know and I haven't found how to solve them.
For example this code that is just a simplified example:
@MainActor class ATextModel: ObservableObject {
@Published private(set) var record: CKRecord?
func getData() async {
let database = CKContainer.default().publicCloudDatabase
let query = CKQuery(recordType: "Test", predicate: NSPredicate(value: true))
do {
let results = try await database.records(matching: query)
self.record = try results.matchResults.first?.1.get()
} catch {
print("Error: \(error.localizedDescription)")
}
}
}
Is giving me 2 warnings:
Non-sendable type '(matchResults: [(CKRecord.ID, Result<CKRecord, any Error>)], queryCursor: CKQueryOperation.Cursor?)' returned by call from main actor-isolated context to non-isolated instance method 'records(matching:inZoneWith:desiredKeys:resultsLimit:)' cannot cross actor boundary
Non-sendable type 'CKQuery' exiting main actor-isolated context in call to non-isolated instance method 'records(matching:inZoneWith:desiredKeys:resultsLimit:)' cannot cross actor boundary
Does someone has a hint on how I should do this now?
This might be just an error in the beta, but I don't really think that.