Dive deeper into SwiftData

RSS for tag

Discuss the WWDC23 Session Dive deeper into SwiftData

Posts under wwdc2023-10196 tag

23 Posts

Post

Replies

Boosts

Views

Activity

Cannot use instance member within property initializer
I've been trying to use the example from this session to tweak the default SwiftData template, allowing for syncing of the data across devices. When I added the following code, I get the above error: @main struct ItemApp: App { let items = ModelConfiguration(schema: Schema([Item.self]), url: URL(filePath: "/path/to/item.store"), cloudKitContainerIdentifier: "iCloud.com.app.Item") let container = try ModelContainer(for: items). // ERROR HERE var body: some Scene { WindowGroup { ContentView() } .modelContainer(container) } } Cannot use instance member 'items' within property initializer; property initializers run before 'self' is available Any pointers would be helpful.
3
1
1.6k
Jun ’23
CloudKit data change notification via CKSubscription
Before SwiftData we used CKSubscriptions to subscribe to changes in the CloudKit container made by uses of our app. We could listen for remote notifications and act upon those. With SwiftData we can specify a CloudKit container for our app but I did not see any update to the usage of CKSubscription and also no updates notes on populating the CloudKit schema beforehand, use of the dev or prod containers etc... Has any of that changed with the advent of SwiftData?
0
1
744
Jun ’23
Cannot use instance member within property initializer
I've been trying to use the example from this session to tweak the default SwiftData template, allowing for syncing of the data across devices. When I added the following code, I get the above error: @main struct ItemApp: App { let items = ModelConfiguration(schema: Schema([Item.self]), url: URL(filePath: "/path/to/item.store"), cloudKitContainerIdentifier: "iCloud.com.app.Item") let container = try ModelContainer(for: items). // ERROR HERE var body: some Scene { WindowGroup { ContentView() } .modelContainer(container) } } Cannot use instance member 'items' within property initializer; property initializers run before 'self' is available Any pointers would be helpful.
Replies
3
Boosts
1
Views
1.6k
Activity
Jun ’23
SwiftData and Multiple Users
Cannot see details about in preview documentations. (I have read old Coredata docs) Any ref in new APIs?
Replies
0
Boosts
1
Views
847
Activity
Jun ’23
CloudKit data change notification via CKSubscription
Before SwiftData we used CKSubscriptions to subscribe to changes in the CloudKit container made by uses of our app. We could listen for remote notifications and act upon those. With SwiftData we can specify a CloudKit container for our app but I did not see any update to the usage of CKSubscription and also no updates notes on populating the CloudKit schema beforehand, use of the dev or prod containers etc... Has any of that changed with the advent of SwiftData?
Replies
0
Boosts
1
Views
744
Activity
Jun ’23