Trying to have a delegate pattern with a typealias requirement. I can define 
the protocol, I can make a class conform to it, but I can’t declare a variable 
of that type as a member of another class because it has associated type 
information. Is there a way to do this, or is there a very good reason what I’m 
trying to do doesn’t make sense? 

public protocol Foo : class
{
        typealias Key
        func foo( k : Key )->()
}

public class FooClass : Foo
{
        typealias Key = Int

        public func foo( k : Int )->()          // satisfies the protocol 
requirement
        {
                print( "Satisfies Foo" )
        }
}


public class Bar<Key>
{
        var delegate : Foo              // Protocol ‘Foo’ can only be used as a 
generic constraint because … 
}


You see what I’m trying to mean here right, that the Foo here is a Foo with 
associated type ‘Key’. 

I really want to be able to qualify the Foo with a where clause like

        var delegate : Foo where Foo.Key == Key

but you can’t use where clauses like that. Is there a way to write this or is 
this something which cannot be written. 
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to