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.

45 lines
1.1 KiB

6 years ago
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 stringRemovingComma() -> String {
  23. return components(separatedBy: ",").joined()
  24. }
  25. func getDateFromDateTime() -> String {
  26. return components(separatedBy: .whitespaces)[0]
  27. }
  28. func removeSpacesTrailingPreceding() -> String {
  29. return trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
  30. }
  31. func capitalizeFirstLetter() -> String {
  32. let first = String(characters.prefix(1)).capitalized
  33. let other = String(characters.dropFirst())
  34. return first + other
  35. }
  36. }