Hello David, thanks for reaching out.

Let's go over the list of problems you have found:

  1. Basically just objects can have weak references, so we have to somehow say that out `T` is a object. You can do it easily by restricting the type like T: AnyObject. You have to apply it to the protocol and to the WeakReference object too. Something interesting would be to say that the protocol is of @objc too, it will let the compiler happy;
  2. Basically what we're trying to do here is to check if that object is already in the list. You can solve it by adding an ID to the protocol, so each object will have a different unique ID. Or you can say that you object will be a type of object that conforms to Equatable.
  3. You got it! Just add value to the call of the initializer.

Thanks again for leaving a comment. I updated the Gists in the post. Let me know if it's working on your side!

Computer Engineer + iOS Engineer. I am interested in Swift, Kotlin, Firebase, Data Structures, ASO & On Solving Real World Problems.

Computer Engineer + iOS Engineer. I am interested in Swift, Kotlin, Firebase, Data Structures, ASO & On Solving Real World Problems.