Skip to content

0.7.0

Choose a tag to compare

@fatbobman fatbobman released this 27 Feb 08:30
· 195 commits to main since this release

What's New

New API: withContext

All @NSModelActor and @NSMainModelActor actors now gain two new methods via the NSModelActor protocol extension, enabling direct synchronous access to the underlying Core Data context from within the actor's isolation boundary.

// Inspect persistent store state in tests — context only
try await handler.withContext { context in
    let items = try context.fetch(Item.fetchRequest())
    #expect(items.count == 1)
}

// Also access the container for cross-context verification
try await handler.withContext { context, container in
    let verificationContext = container.newBackgroundContext()
    let items = try verificationContext.fetch(Item.fetchRequest())
    #expect(items.count == 1)
}

Both overloads require T: ​Sendable, preventing managed objects from accidentally escaping the actor's isolation boundary.

Internal Cleanup

• Removed the unreachable enqueue(_ job: consuming ​Executor​Job) overload from NSModel​Object​Context​Executor. The enqueue(​Unowned​Job) path covers all supported OS versions (iOS 13+).

Documentation

• Added NSModelActor Protocol API section to README covering model​Context, model​Container, the subscript accessor, and with​Context usage examples.