If the protocol declares that there is a getter and setter of type [AnyObject], than this means that there should be such a getter and setter, and not a subtype of this class.
Your code will be logically incorrect - because you could set, for example, some [Int] (the protocol says it is possible) a variable of the type [Foo] (the class only has this var)
So this is actually the only right way.
protocol Parent { var children: [AnyObject] { get set } } class Foo { } class Bar: Parent { //error happens here var children = [AnyObject]() init() {} }
In swift 2.0 typealias may be another option.
Pavel Smejkal
source share