Voyager Voyager - 1 year ago 90
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?

Answer Source

What you should do is probably following:

for (key, value) in dict {
    let person = Person(person: [key: value])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download