Skip to content

Commit 740e869

Browse files
committed
Merge branch 'develop'
2 parents f48cedd + e96080b commit 740e869

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

Sources/ManagedModels/Container/ModelConfiguration.swift

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Created by Helge Heß.
3-
// Copyright © 2023 ZeeZide GmbH.
3+
// Copyright © 2023-2024 ZeeZide GmbH.
44
//
55

66
@preconcurrency import CoreData
@@ -117,11 +117,13 @@ public extension ModelConfiguration {
117117

118118
public extension ModelConfiguration {
119119

120+
@inlinable
120121
var url : URL {
121122
set { path = newValue.path }
122123
get { URL(fileURLWithPath: path) }
123124
}
124125

126+
@inlinable
125127
init(_ name: String? = nil, schema: Schema? = nil, url: URL,
126128
isStoredInMemoryOnly: Bool = false, allowsSave: Bool = true,
127129
groupAppContainerIdentifier: String? = nil,
@@ -138,6 +140,18 @@ public extension ModelConfiguration {
138140
groupContainer: groupContainer,
139141
cloudKitDatabase: cloudKitDatabase)
140142
}
143+
144+
@inlinable
145+
init(isStoredInMemoryOnly: Bool) {
146+
self.init(schema: nil, isStoredInMemoryOnly: isStoredInMemoryOnly)
147+
}
148+
@inlinable
149+
init(for forTypes: any PersistentModel.Type...,
150+
isStoredInMemoryOnly: Bool = false)
151+
{
152+
let model = NSManagedObjectModel(forTypes)
153+
self.init(schema: model, isStoredInMemoryOnly: isStoredInMemoryOnly)
154+
}
141155
}
142156

143157
private func lookupDefaultPath(for name: String?) throws -> String {

Sources/ManagedModels/PersistentModel/PersistentIdentifier.swift

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
//
22
// Created by Helge Heß.
3-
// Copyright © 2023 ZeeZide GmbH.
3+
// Copyright © 2023-2024 ZeeZide GmbH.
44
//
55

66
import CoreData
77

88
public typealias PersistentIdentifier = NSManagedObjectID
99

10-
extension NSManagedObjectID: Identifiable {
11-
10+
#if compiler(>=6)
11+
extension NSManagedObjectID: @retroactive Identifiable, @retroactive Encodable {
12+
}
13+
#else
14+
extension NSManagedObjectID: Identifiable, Encodable {}
15+
#endif
16+
17+
extension NSManagedObjectID {
1218
public typealias ID = NSManagedObjectID
1319

1420
@inlinable
1521
public var id: Self { self }
1622
}
1723

18-
extension NSManagedObjectID: Encodable {
24+
extension NSManagedObjectID {
1925

2026
@inlinable
2127
public func encode(to encoder: Encoder) throws {

0 commit comments

Comments
 (0)