Bring Core Data concurrency to Swift and SwiftUI

RSS for tag

Discuss the WWDC21 session Bring Core Data concurrency to Swift and SwiftUI.

View Session

Posts under wwdc21-10017 tag

23 Posts
Sort by:
Post not yet marked as solved
0 Replies
319 Views
I want to implement this pattern in my app: let moc = ...newBackgroundContext() try await moc.perform { // test for existence of a specific object in the moc if !objectExists { let apiObject = await api.fetchObjectFromNetwork() // create managed object from apiObject try moc.save() } } Unfortunately, I am unable to await my network call because the moc.perform block is not async. So far, I've come up with this solution: let moc = ...newBackgroundContext() try await moc.perform { // test for existence of a specific object in the moc if !objectExists { Task { let apiObject = await api.fetchObjectFromNetwork() try await moc.perform { // create managed object from apiObject try moc.save() } } } } But it doesn't feel quite right. What do you think? Am I on the right track, or am I introducing unneeded complexity?
Posted
by beruk.
Last updated
.
Post not yet marked as solved
0 Replies
533 Views
Update Error BigSur Beta > Finding available software Downloading macOS Big Sur 11.5 Beta 2 Password: Downloading: 100.00% Failed to download & prepare update: Error Domain=SUMacControllerError Code=7721 "[SUMacControllerErrorPreflightWakeupFailed=7721] Failed to perform PreflightWakeup operation: [MobileSoftwareUpdateErrorDomain(MSU):819]" UserInfo={NSUnderlyingError=0x127908c80 {Error Domain=MobileSoftwareUpdateErrorDomain Code=819 "softwareupdated relaunch needed to load new brain" UserInfo={NSDebugDescription=softwareupdated relaunch needed to load new brain}}, SUMacControllerErrorIndicationsMask=0, NSDebugDescription=[SUMacControllerErrorPreflightWakeupFailed=7721] Failed to perform PreflightWakeup operation: [MobileSoftwareUpdateErrorDomain(MSU):819], NSLocalizedDescription=Failed to launch the software update installer. Please try again.} https://store-028.blobstore.apple.com/v01/FR/0433/8681/0000/16782909/sysdiagnose_2021.06.06_15-45-23%2B0000_macOS_MacBookAir10-1_20G5023d.tar.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=MKIA0879Y5FEZQ0RYD6Z%2F20210608%2Fstore-028%2Fs3%2Faws4_request&X-Amz-Date=20210608T164714Z&X-Amz-Expires=15&X-Amz-SignedHeaders=host&X-Amz-Signature=70a6152d9b55d98b7e487329fa2813a95770fe8dd489cea7a7e0aed32a838bb1 24/12HR , >> DAY WEEK YEAR . WEEK DAY YEAR << US & EU ,,
Posted
by xcom.
Last updated
.
Post not yet marked as solved
1 Replies
493 Views
Let's say I have a Person entity in my core data model that has a name attribute of type String. I want to use a sectioned fetch request to list my Person entities sectioned by the first letter of their name. I wrongly assumed I could just add a property to my NSManagedObject subclass and use it in a sectioned fetch request as follows extension Person { var firstLetterOfName: String { // get the first letter } } @SectionedFetchRequest(     sectionIdentifier: \.firstLetterOfName,     sortDescriptors: [ SortDescriptor(\.name, order: .forward) ]) var people: SectionedFetchResults<String, Person> However, I end up with an uncaught exception NSUnknownKeyException How can I define this property in a way that I can use it in the section identifier?
Posted Last updated
.