0
votes

I have 2 different classes (NSObject, RealmObject) that should conform to one common protocol Listening.

protocol Listening: class {
  var filter: String? { get }
}

Then I have this parent class that has array var allListeningObjects: [Listening] which should hold all objects that conform to this protocol. But before I can run it, I get this error: Type 'Listening' does not conform to protocol 'Hashable'

Im open to any advice that can make this work.

1

1 Answers

2
votes

Considering the error you are getting - it would seem you are attempting to you use your Listening protocol as a the type of a key in a dictionary or as the type of element in a set - and not as the type of the elements in an array. Double check the type definition of the allListeningObjects and ensure it is actually an array, not a set or dictionary.

If you are intending to use your Listening protocol in this context - Apple has some nice documentation on how to implement Hashable