         self.passwordField.secureTextEntry = true
         self.passwordField.autocapitalizationType = UITextAutocapitalizationType.None
         self.passwordField.returnKeyType = UIReturnKeyType.Go
-        self.passwordField.delegate = self
         
         self.loginButton = UIButton()
         self.loginButton.titleLabel!.font = UIFont(name: "Lato-Regular", size: 16)
         self.loginButton.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
         self.loginButton.setTitle("Login", forState: UIControlState.Normal)
-        self.loginButton.addTarget(self, action: "loginTapped:", forControlEvents: UIControlEvents.TouchUpInside)
         
         self.tableView = UITableView(frame: CGRectZero, style: UITableViewStyle.Grouped)
+        
         super.init()
+        
+        self.usernameField.delegate = self
+        self.passwordField.delegate = self
+        self.loginButton.addTarget(self, action: "loginTapped:", forControlEvents: UIControlEvents.TouchUpInside)
     }
     
     override func loadView() {

    }
    
    func validateFields() -> Bool {
    }
}

        self.usernameField.placeholder = "Username"
        self.usernameField.autocapitalizationType = UITextAutocapitalizationType.None
        self.usernameField.returnKeyType = UIReturnKeyType.Next
        
        self.passwordField = UITextField()
        self.passwordField.font = UIFont(name: "Lato-Regular", size: 16)
