Feedback made: FB12313651
Post
Replies
Boosts
Views
Activity
I'm filling a bug report on this.
I had the same issue. What I wound up doing is creating a "filter" function which iterated through the CKRecords and removed records which did not match my search criteria. Here's the business part of that code.
guard var records = theRecords else {return nil}
for (index, record) in records.enumerated().reversed() {
if let keyResult = record[keyWord] as? String {
let resultString = keyResult.lowercased()
if !resultString.contains(searchWord.lowercased()) {
records.remove(at: index)
}
}
}
The issue is fixed. What was the problem? I had another line of code following the records line in which I did not set desiredKeys. Here's the line of code.
let (continuingMatchResults, cMatchCursor) = try await database.records(continuingMatchFrom: queryCursor!)
Oince I changed it to
let (continuingMatchResults, cMatchCursor) = try await database.records(continuingMatchFrom: queryCursor!, desiredKeys: desiredKeys)
all was well.
The Apple document on CKAsset states the following. "If you don’t require the asset when retrieving records, use the operation’s desiredKeys property to exclude the field." But this doesn't work, at least for the function
var (matchResults, queryCursor) = try await database.records(matching: query, desiredKeys: desiredKeys)
Any thoughts from anybody?
Use Swift Playgrounds on an iPad. Use Xcode on a Mac.
When you use the WatchConnectivityManager, do you update the applicationContext on the main thread? If not, that may be part of your connectivity problem.
I've decided to use Core Data with CloudKit for the user's private data.
I know it's great for those new to Core Data and CloudKit for the system to automatically create record fields in CloudKit, but in this case, I wish I had control over the result to define this piece of binary data as a CKAsset in CloudKit. I will never manipulate the CloudKit data directly, but it would be nice to have consistency in the linking of Core Data binary data to CloudKit fields.
I'm running the app in the Development environment and have not committed the CloudKit Schema to the Production environment.
I've figured out a way to fix my remaining two issues. I'm making this as done.
The issue is that CKRecord is not sendable, so the worry is that different threads could change the same CKRecord object, thus causing problems. There is a dangerous way to turn off the warnings.
extension CKRecord: @unchecked Sendable {
}
Telling the compiler to turn off the warnings. In my app, as I have mentioned before, I have a CKMethods protocol that other View Controllers use. I have never had an issue with CKRecord not being sendable before this compiler update. I am working on a new update to my app and have turned done the above dangerous move, but I welcome a solution that fixes the issue while keeping why code basically in tact.
I have a similar situation. I have a CKMethods protocol which I use in a number of View Controllers. I get warnings about CKRecord not being sendable. What I've been doing to try to fix it is to move the functions into the View Controllers. But now I'm stuck with this among other warnings.
let matchTemp = try await database.records(for: recIDs)
Non-sendable type '[CKRecord.ID : Result<CKRecord, any Error>]' returned by call from main actor-isolated context to non-isolated instance method 'records(for:desiredKeys:)' cannot cross actor boundary
Here's another one.
let results = try await database.modifyRecords(saving: records, deleting: [], savePolicy: .allKeys, atomically: false)
Non-sendable type '[CKRecord]' exiting main actor-isolated context in call to non-isolated instance method 'modifyRecords(saving:deleting:savePolicy:atomically:)' cannot cross actor boundary
Try something like this. Adjust the position as needed.
textEntity.setPosition(SIMD3<Float>(0.2, 0.2, 0.2), relativeTo: anchor)
anchor.addChild(textEntity)