NullHypothesis
NullHypothesis

Reputation: 4506

Any thoughts on why this Swift code does not compile?

Anything wrong with this syntax?

protocol Serializable
{  
    init(dictionary:[NSObject:AnyObject])  
}

I'm getting an error with this line. I'm following this example.

I just can't seem to get it to work. Thanks!

Upvotes: 4

Views: 120

Answers (1)

Connor
Connor

Reputation: 64644

The syntactic sugar for Array and Dictionary changed in beta 3. This code won't work in the first or second beta, but will work in a newer version.

If you want the code to work in an earlier version, just remove the syntactic sugar:

protocol Serializable
{
    init(dictionary: Dictionary<NSObject, AnyObject>)
}

Upvotes: 1

Related Questions