Within a view, problem iterating over dictionary - RandomAccessCollection error
04:32 05 Jan 2026

Within body of ContentView I am tring to use ForEach to iterate over a dictionary that is within the instance of a class. The dictionary contains instances of another class.

The compiler reports Generic struct 'ForEach' requires that '[String:NodeGroup]' conforms to 'RandomAccessCollection'

I have:

struct NodeGroup {  
    let id = UUID()  
    var groupId: String  
    var groupName: String  
}

struct NodeNetwork {  
    let id = UUID()  
    var nodeGroups: [String: NodeGroup] = [:]  
}

struct ContentView: View {  
    var body: some View {  
        let networkModel: NodeNetwork = loadNetwork()  
        var homeGroups = networkModel.nodeGroups  
        ForEach(homeGroups, id:\.self) { homeGroup in  
           ....  
        } 
swift