Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. //
  2. // ViewController.swift
  3. // UserRegistration
  4. //
  5. // Created by h01 on 2017-10-02.
  6. // Copyright © 2017 h01. All rights reserved.
  7. //
  8.  
  9. import Cocoa
  10.  
  11. class ViewController: NSViewController {
  12.  
  13. @IBOutlet weak var userName: NSTextField!
  14. @IBOutlet weak var userPassword: NSTextField!
  15. @IBOutlet weak var output: NSTextField!
  16.  
  17.  
  18. @IBAction func loginButton(_ sender: Any) {
  19.  
  20.  
  21. let X = userPassword
  22.  
  23. let Y = userName
  24.  
  25.  
  26. if validateUsername(text : (Y?.stringValue)! )
  27.  
  28. {
  29.  
  30.  
  31.  
  32. if validatePassword(text : (X?.stringValue)! )
  33.  
  34. {
  35.  
  36. output.stringValue = "You are Logged in" }
  37.  
  38.  
  39.  
  40. else
  41. {
  42. output.stringValue = "Incorrect Password"
  43. }
  44.  
  45.  
  46.  
  47. }
  48.  
  49.  
  50.  
  51.  
  52. else
  53.  
  54. {
  55. output.stringValue = "Incorrect username"
  56. }
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. }
  67.  
  68.  
  69. @IBAction func registerButton(_ sender: Any) {
  70.  
  71.  
  72.  
  73.  
  74. }
  75.  
  76. func validatePassword (text : String) ->Bool {
  77. var result = false
  78. if text == "123"
  79. {
  80. result = true
  81. }
  82. return result
  83. }
  84.  
  85. func validateUsername (text : String) ->Bool {
  86. var result = false
  87. if text == "123"
  88. {
  89. result = true
  90. }
  91. return result
  92. }
  93.  
  94.  
  95.  
  96.  
  97.  
  98. override func viewDidLoad() {
  99. super.viewDidLoad()
  100.  
  101. // Do any additional setup after loading the view.
  102. }
  103.  
  104. override var representedObject: Any? {
  105. didSet {
  106. // Update the view, if already loaded.
  107. }
  108. }
  109.  
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement