How to pass dictionary as a parameter in the method in Swift?

I have created following method in my code:

func SignIn(objDictionary:Dictionary<String,String>)
    //Body of method

I need to pass the following dictionary as a parameter in this method which is defined below:

  • OSStatus error 1685348671 AVAudioPlayer
  • Swift and using class extension
  • Return Bool in Alamofire closure
  • Uploading file with parameters using Alamofire
  • What happens if two ObjC categories override the same method?
  • Updating to latest version of cocoapods?
  • let objSignInDictionary:Dictionary = ["email":emailTextField.text, "password":passwordTextField.text]

    How can I pass this dictionary in the above method as a parameter?

    This should be noted that method is in another class and I am calling the method by creating its object as follows:

    let obj = Services()

    SignIn is defined in Services.swift class
    so I am trying to call it like


    but getting following error

    "String!" is not identical to "String"

    Where I am wrong and how it can be fixed. I am stuck here since couple of days.

    Solutions Collect From Internet About “How to pass dictionary as a parameter in the method in Swift?”

    If you alt+click objSignInDictionary in Xcode you will see its inferred as [String : String!]. You can fix this by explicitly setting objSignInDictionary type:

    let objSignInDictionary:[String:String] = ["email":emailTextField.text, "password":passwordTextField.text]