Wednesday 15 February 2012

ios - Pass parameter's datatype not consistent as it's declared -



ios - Pass parameter's datatype not consistent as it's declared -

i'm new swift, followed treehouse lesson,

allow currentweather = current(weatherdictionary: weatherdictionary)

and don't know why should utilize current(weatherdictionary: weatherdictionary) pass compile

but not current(weatherdictionary: nsdictionary)

because think declared weatherdictionary nsdictionary type

controller allow weatherdictionary: nsdictionary = nsjsonserialization.jsonobjectwithdata(dataobject, options: nil, error: nil) nsdictionary allow currentweather = current(weatherdictionary: weatherdictionary) current struct struct current { var currenttime: string? var temperature: int var humidity: double var summary: string var icon: string init(weatherdictionary: nsdictionary){

weatherdictionary name of instance, that's why need utilize it.

you declared parameter nsdictionary, that's it. when using using named parameter (name: instance); first parameter name, , sec 1 object instance wich needs of type nsdictonary.

ios swift

No comments:

Post a Comment