0

I've added screenshots below. I'm delighted to see you. Thank you

user login Screen

Error

override func viewDidLoad() {
    super.viewDidLoad()

    let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissKeyboard")
    view.addGestureRecognizer(tap)

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

@IBAction func btnGirisYap(_ sender: Any) {
    var pass : String!

I assign txtGirisSifre.text as variable "pass"

    let arayüzPass = txtGirisSifre.text
    var request = URLRequest(url: URL(string: "http://242.253.114.125:7001/WebApplicationo2/login")!)
    request.httpMethod = "POST"
    let postString = "user=emrekacan"
    request.httpBody = postString.data(using: .utf8)
    let task = URLSession.shared.dataTask(with: request) { data, response, error in
        if error != nil
        {
        }
        else
        {
            if let urlContent = data
            {
                do
                {

                    let jsonResult = try JSONSerialization.jsonObject(with: urlContent, options: JSONSerialization.ReadingOptions.mutableContainers) as AnyObject

                    if let currencyRate  = jsonResult as? NSArray
                    {

                        for i in 0..<currencyRate.count
                        {
                            if let gelenPass = (currencyRate[i] as? NSDictionary)?["pass"] as? String
                            {
                                pass = gelenPass
                                print(pass)
                                print(arayüzPass!)

                            }
                        }

If the password that is called web service is not empty in this section

                        if pass != nil {
                            self.login(pass1: pass , arayüzPass1: arayüzPass!)
                        }
                    }
                  }

                catch
                {

                }
            }
        }
    }
 task.resume()
}

func dismissKeyboard() {
    //Causes the view (or one of its embedded text fields) to resign the first responder status.
    view.endEditing(true)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
    textField.resignFirstResponder()
    return true
}

It gives an error after this section

func login(pass1 : String , arayüzPass1 : String!)
{

"SWRevealViewController" storyboard open

    if pass1 == arayüzPass1 {
        let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
        let resultViewController = storyBoard.instantiateViewController(withIdentifier: "RevealView") as! SWRevealViewController
        self.present(resultViewController, animated:true, completion:nil)

    }
}
}
emre
  • 21
  • 4
  • within the 2nd image it has **reason:** `[ios uikeyboardtaskqueue waituntilalltasksarefinished]` may only be called from main queue...so you MUST put it inside a `DispatchQueue.main.async { // do your code here }` + instead of `if let` use `guard`. see [here](http://stackoverflow.com/questions/32256834/swift-2-0-guard-vs-if-let). ALWAYS try to read the console and understand what it is trying to say you to. usually it's followed by the word *reason*. – mfaani Dec 05 '16 at 21:39
  • hey , Thank you very much :) – emre Dec 05 '16 at 21:42

0 Answers0