Dictionary value by key -


while trying value dictionary, xcode showing me following error:

could not find overload 'subscript' accepts supplied arguments

class func fromdictionary(enterprisedictionary:dictionary<string, anyobject>) -> enterprise {     var enterprise:enterprise = enterprise()      enterprise.id = enterprisedictionary["id"] int  (error occurs here)     enterprise.name = enterprisedictionary["name"] as? string ( , here )       return enterprise } 

i managed resolve question replacing "anyobject" "any" seen below:

class func fromdictionary(enterprisedictionary:dictionary<string, any>) -> enterprise {     var enterprise:enterprise = enterprise()      enterprise.id = enterprisedictionary["id"] int     enterprise.name = enterprisedictionary["name"] as? string       return enterprise } 

as @andrey tarantsov said:

this occurs because anyobject class instance (you can think of objects in objective-c sense); string , int not classes.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -