so ive got an actor that im using to control concurrent access to some shared data.
I have a second actor that controls concurrent access to another set of different shared data
actor DataManager {
static let shared = DataManager()
func fetchData() async {
modifySomeData()
let blah = await SecondDataManager.shared.fetchDifferentData()
}
}
actor SecondDataManager {
static let shared = SecondDataManager()
func fetchDifferentData() -> [SomeData] {
return stuff
}
}
im finding that because of the await in the fetchData() method, the actor no longer ensures that the DataManager.fetchData() function can only be executed one at a time thus corrupting my shared data because fetchData() needs to be async due to the call on the second actor method.
Any way to ensure DataManager.fetchData() can only be executed one at a time? normally id use a DispatchQueue or locks. but it seems these can't be combined with actors.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
anyone know how to use the new swift concurrency model (ie. await context.perform and context.perform) core data willSave()?
for example. how would I ensure this is thread safe? changing self.managedObjectContext!.performAndWait to await self.managedObjectContext!.perform means I have to change willSave() to async which then means it never gets called because its not overriding the correct method anymore.
override public func willSave() {
self.managedObjectContext!.performAndWait {
if self.modifiedDate == nil || Date().timeIntervalSince(self.modifiedDate!) >= 1 {
self.modifiedDate = Date()
}
}
super.willSave()
}
Ive been getting this error on an app in the dev environment since iOS16. it continues to happen in the latest iOS release (iOS18).
After this error/warning, CoreData_CloudKit stops syncing and the only way to fix it is to delete the app from all devices, reset the CloudKit dev environment, reload the schema and reload all data. im afriad that if I ever go live and get this error in production there won't be a way to fix it given I cant go and reset the production CloudKit environment.
It doesn't happen straight away after launching my app in a predictable manner, it can take several weeks to happen.
Ive posted about this before here and haven't got a response. I also have a feedback assistant issue submitted in 2022 as part of ios16 beta that is still open: FB10392936 for a similar issue that caused the same error.
would like to submit a code level support query but it doest seem to have anything to do with my code - but rather the Apple core data CloudKit syncing mechanism.
anyone have any similar issues or a way forward?
> error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _requestAbortedNotInitialized:](2200): <NSCloudKitMirroringDelegate: 0x301e884b0> - Never successfully initialized and cannot execute request '<NSCloudKitMirroringImportRequest: 0x3006f5a90> D823EEE6-EFAE-4AF7-AFED-4C9BA708703B' due to error: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x73, 0x61, 0x6d)" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x53, 0x6f, 0x6d, 0x65, 0x20, 0x73, 0x61, 0x6d)}
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
CloudKit
CloudKit Console
CloudKit Dashboard
Core Data