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.

41 lines
1.0 KiB

6 years ago
  1. //
  2. // StringExtension.swift
  3. // GMERemittance
  4. //
  5. // Created by Sujal on 12/13/17.
  6. // Copyright © 2017 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. extension String {
  10. var isBlank: Bool {
  11. get {
  12. return trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty
  13. }
  14. }
  15. func toBase64() -> String {
  16. let data = self.data(using: String.Encoding.utf8)
  17. return data!.base64EncodedString()
  18. }
  19. func removeWhitespacesInBetween() -> String {
  20. return components(separatedBy: .whitespaces).joined()
  21. }
  22. func getDateFromDateTime() -> String {
  23. return components(separatedBy: .whitespaces)[0]
  24. }
  25. func removeSpacesTrailingPreceding() -> String {
  26. return trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
  27. }
  28. func capitalizeFirstLetter() -> String {
  29. let first = String(characters.prefix(1)).capitalized
  30. let other = String(characters.dropFirst())
  31. return first + other
  32. }
  33. }