Voyager Voyager - 9 months ago 42
Swift Question

Swift (String:AnyObject) is not convertible to [String:AnyObject]

Hi I got a code like this but the Xcode show an error:

(String:AnyObject) is not convertible to [String:AnyObject]

func personDetails (dic : [String:AnyObject]) -> Array<Person> {
for personDic: [String : AnyObject] in dict { >> error in this line
let person = Person.init(person: personDic)
//rest the code

How to make it correct?


What you should do is probably following:

for (key, value) in dict {
    let person = Person(person: [key: value])