I'm trying to understand why this won't work:
protocol MyProtocol: AnyObject { }
let arrayOfMyProtocol: [MyProtocol] = []
let arrayOfAnyObject: [AnyObject] = arrayOfMyProtocolLine 3 gives me the error "Cannot convert value of type `[MyProtocol]` to specified type `[AnyObject]`.
I can fix by changing the last line to:
let arrayOfAnyObject: [AnyObject] = arrayOfMyProtocol.map { $0 }But I don't understand why or if it's really neccessary to creaete a new copy of the array.
Thanks,
Jesse