UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

selection: Set<Object.ID> but ID is inaccessible

Forums > SwiftUI

When alphabetizing the var list causes hours of debugging:

When adding multiple selection to a Table

@State private var sortOrder = [KeyPathComparator(\Account.name)]
@State private var selection: Set<Account.ID> = []

compiles but this does not:

@State private var selection: Set<Account.ID> = []
@State private var sortOrder = [KeyPathComparator(\Account.name)]

It does not have to be a keypath definition that comes before Set<Account.ID> but any code that references the SwiftData Account object. Not sure why but even in the simplest test view the standalone selection definition gave the error:

'ID' is inaccessible due to 'internal' protection level

I'd appreciate any insight as to why this might be the case. Should I be looking at the app setup, the Schema, ??

   

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.