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.

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alcivanio (Swift)

Alcivanio (Swift)

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

More from Medium

If I were a Bird

Something New…

Who among us will become extinct?