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

//
// StringExtension.swift
// GMERemittance
//
// Created by Sujal on 12/13/17.
// Copyright © 2017 Gobal Money Express Co. Ltd. All rights reserved.
//
import Foundation
extension String {
var isBlank: Bool {
get {
return trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty
}
}
func toBase64() -> String {
let data = self.data(using: String.Encoding.utf8)
return data!.base64EncodedString()
}
func removeWhitespacesInBetween() -> String {
return components(separatedBy: .whitespaces).joined()
}
func getDateFromDateTime() -> String {
return components(separatedBy: .whitespaces)[0]
}
func removeSpacesTrailingPreceding() -> String {
return trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
func capitalizeFirstLetter() -> String {
let first = String(characters.prefix(1)).capitalized
let other = String(characters.dropFirst())
return first + other
}
}