ios - “type of expression is ambiguous without more context” using struct property as dictionary key -


i getting , exception:

type of expression ambiguous without more context

with following code:

struct parameter {      static let email = "email"      static let password = "password"      static let isfacebookuser = "isfacebookuser"  }  let parameters : [string : anyobject] = [parameter.email : email, parameter.password : password, parameter.isfacebookuser : false] 

it's not accepting bool type , don't want change data type.

is there issue in code?

your email , password optional variables, need provide non-nil values dictionary and, hence, should unwrap them using ! suffix try this

let parameters : [string : anyobject] = [parameter.email : email!, parameter.password : password!, parameter.isfacebookuser : false] 

alternatively, can do

email = emailtextfield.text! password = passwordtextfield.text! 

also, replace struct enum.

enum parameter: string {     case email: "emailkey"     ... } 

and use parameter.email.rawvalue while creating dictionary.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -