Been struggling with this kind of problem. My case: I have an array of class protocol and can’t use my extension that removes AnyObject from array by comparing pointers via ===.
This issue bites me frequently and is a barrier to clean "protocol-based” programming. This is extremely counter-intuitive to me, at least. Not having a good workaround for this really makes the language seem incomplete.
Recently I had the need to use instances of a protocol as keys in a dictionary (yes, there was a very good reason for it). I assume that this was the reason that I could get it to work. I ended-up having the use instances of an abstract class, but of course, the powers that be think that abstract classes should be second-class citizens in Swift. This is off-topic, but not having a good construct for abstract methods was a mistake in Obj-C and it is a mistake in Swift.
- Chris
···
On Dec 6, 2016, at 12:30 PM, Андрей Володин via swift-evolution <swift-evolution@swift.org> wrote:
Been struggling with this kind of problem. My case: I have an array of class protocol and can’t use my extension that removes AnyObject from array by comparing pointers via ===.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
The need to use === is at the root of my problem as well.
Charles
···
On Dec 6, 2016, at 1:30 PM, Андрей Володин via swift-evolution <swift-evolution@swift.org> wrote:
Been struggling with this kind of problem. My case: I have an array of class protocol and can’t use my extension that removes AnyObject from array by comparing pointers via ===.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution