         dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"
         return dateFormatter.stringFromDate(date)
     }
-    
+
     func textFieldShouldReturn(userText: UITextField) -> Bool {
         userText.resignFirstResponder()
         return true;

            }
        }
    }
    
    func uploadPhoto(imageData: NSData, index: Int, totalNumber: Int, creationDate: NSDate) throws {
        self.updateStatus("Uploading: " + String(index) + "/" + String(totalNumber))
        
        let host = self.host.text
        let port = self.port.text
        let username = self.username.text
        let password = self.password.text
        let session = NMSSHSession(host: host, port: Int(port!)!, andUsername: username)
        
        session.connect()
        guard session.connected else {
            throw ConnectionError.NotConnected
        }
        
        session.authenticateByPassword(password)
        guard session.authorized else {
            throw ConnectionError.NotAuthorized
        }
        
        let sftpSession = NMSFTP.connectWithSession(session)
        let date = formatDate(creationDate)
        let filePath =  self.remoteDir.text! + "/" + date + ".jpg"

        
        session.disconnect()
    }

    func updateStatus(status: String) {
        dispatch_async(dispatch_get_main_queue()) {
            self.statusLabel.text = status;
            self.statusLabel.sizeToFit()
        }
    }

    func formatDate(date: NSDate) -> String {
        let dateFormatter = NSDateFormatter()
        let enUSPosixLocale = NSLocale(localeIdentifier: "en_US_POSIX")
