Post

Replies

Boosts

Views

Activity

CoreData: fetching and uploading data to server
I have a scheduled function uses a private queue context to fetch objects from CoreData and uploads them to a server and deletes the fetched objects if successfully uploaded. The upload function is an async function that uses URLSession. context.perform { do { let fetchRequest = NSFetchRequest<CustomEntity> fetchRequest = CustomEntity.fetchRequest() let objects = try context.fetch(fetchRequest) let data = JSONSerialization.data(withJsonObject: objects, options: []) // await uploadToServer(data) // delete after successful upload: objects.forEach(context.delete) try context.save() } catch let error { } } However, this doesn't seem legal though. xcode gives me an error: 'async' call in a function that does not support concurrency. Stuck on how to invoke the async function within the context.perform { } block
0
0
523
Nov ’21
How to designate principal class
I am building an app that uses DeviceActivity framework. Looking at the documentation, I need to subclass (https://developer.apple.com/documentation/deviceactivity/deviceactivitymonitor), I need to "subclass DeviceActivityMonitor and designate the subclass as the principal class of my app extension. I am wondering how to designate my subclass as the principal class. (I am new to iOS development :) .
2
0
940
Aug ’21