Slide 10
Slide 10 text
@ObservableState
struct State {
@Shared(.appStorage(“count”))
var count: Int
}
@ObservableState
struct State {
@Shared(.inMemory(“text"))
var text: String
ɹ
@Shared(.appStorage(“count”))
var count: Int
}
"OZ)BTIBCMF 3FGFSFODF
JO.FNPSZ lUFYUz
BQQ4UPSFHF lDPVOUz
ࢀরڞ༗
LockIsolated<[AnyHashable: any Reference]>
class ValueReference: Reference {
var persistenceKey
: (any PersistenceKey)?
…
}
0CTFSWBUJPO QFSDFQUJPO
ˏPropertyWrapper
struct Shared {
let reference: any Reference
public init(
_ persistenceKey:
some PersistenceKey,
…
) {
…
@Dependency(
PersistentReferencesKey.self
) var references
…
}
…
5IF$PNQPTBCMF"SDIJUFDUVSF TIBSFETUBUFCFUB
struct InMemoryKey: PersistenceKey
1FSTJTUFODF,FZ४ڌࡾॐ࢜Λ࿈Ε͖ͯͨΑ
struct AppStorageKey: PersistenceKey
struct FileStorageKey: PersistenceKey