I'm having a problem, and I can't find the solution, I have an extension of an object Article
, which has a func which creates the object with the data contained in a dictionary passed as a parameter to the func, this is the code:
protocol EntityProtocol {
mutating func createEntityWithDictionary(dictionary: Dictionary<String, AnyObject>)
}
extension Article: EntityProtocol {
func createEntityWithDictionary(dictionary: Dictionary<String, AnyObject>) {
var article: Article! = ModelManager.instance.insertNewEntityName("Article") as Article
for (key: String, value: AnyObject) in dictionary {
switch key {
case kContentTypeKey:
article.contentType = value as String
case kEditorsPickKey:
article.editorsPick = value as Bool
default:
println("Default")
}
}
}
}
Ok, so in another class, I invoke the func passing a dictionary as parameter, but when I write Article.createEntityWithDictionary
it autocompletes the name of the method, but the type of the parameter is Article
instead of Dictionary
, and if I pass a dictionary as parameter XCode says "NSDictionary is not a subtype of 'Article'".
What am I missing here?