You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

6 years ago
  1. //
  2. // ModelExtension.swift
  3. // GMERemittance
  4. //
  5. // Created by Sujal on 12/26/17.
  6. // Copyright © 2017 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class ModelExtension {
  10. var errorMessage: String?
  11. var internetConnection: Box<Bool?> = Box(nil)
  12. var anotherLogin: Box<Bool?> = Box(nil)
  13. func setErrorMessage(message: String) {
  14. errorMessage = message
  15. }
  16. func getErrorMessage() -> String {
  17. if errorMessage != nil {
  18. return errorMessage!
  19. } else {
  20. return "Connection timeout. Please try again."
  21. }
  22. }
  23. func getUserId() -> String {
  24. if let userId = UserDefaults.standard.object(forKey: "com.gmeremit.username") as? String {
  25. return userId
  26. } else {
  27. return ""
  28. }
  29. }
  30. func getLoginPassword() -> String {
  31. if let passwordBase64 = UserDefaults.standard.object(forKey: "com.gmeremit.password") as? String{
  32. let decodedData = Data(base64Encoded: passwordBase64)!
  33. let password = String(data: decodedData, encoding: .utf8)!
  34. return password
  35. } else {
  36. return ""
  37. }
  38. }
  39. }