This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>UIApplicationSceneManifest</key> | |
| <dict> | |
| <key>UIApplicationSupportsMultipleScenes</key> | |
| <false/> | |
| <key>UISceneConfigurations</key> | |
| <dict> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| @main | |
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
| // Override point for customization after application launch. | |
| return true | |
| } | |
| // MARK: UISceneSession Lifecycle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public extension String { | |
| var trimmed: String { | |
| trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) | |
| } | |
| func trim() -> String { | |
| trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public extension String { | |
| var withFirstCapitalized: String { | |
| if isEmpty { | |
| return self | |
| } | |
| let first = substring(start: 0, length: 1) | |
| let other = count > 1 ? self.substring(start: 1, length: count - 1) : "" | |
| return "\(first.uppercased())\(other)" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public extension String { | |
| func substring(start: Int, length: Int) -> String { | |
| if start >= count { | |
| return "" | |
| } | |
| let startIndex = index(self.startIndex, offsetBy: start) | |
| let endIndex: Index | |
| if start + length > count { | |
| endIndex = index(self.startIndex, offsetBy: count) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public extension String { | |
| var asArray: [Character] { | |
| map { $0 } | |
| } | |
| func toArray() -> [Character] { | |
| map { $0 } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public extension String { | |
| var localized: String { | |
| NSLocalizedString(self, comment: "") | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public extension String { | |
| var html: NSAttributedString { | |
| guard let data = data(using: .utf8) else { return NSAttributedString() } | |
| do { | |
| return try NSAttributedString( | |
| data: data, | |
| options: [ | |
| NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html, | |
| NSAttributedString.DocumentReadingOptionKey.characterEncoding: String.Encoding.utf8.rawValue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public extension String { | |
| var asUIColor: UIColor? { | |
| var cString = self.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() | |
| if cString.hasPrefix("#") { | |
| cString.remove(at: cString.startIndex) | |
| } | |
| let allowedCharacters = CharacterSet(charactersIn: "0123456789ABCDEF") | |
| if cString.rangeOfCharacter(from: allowedCharacters.inverted) != nil { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public extension Encodable where Self: Decodable { | |
| func copyCodable() throws -> Self { | |
| let data = try JSONEncoder().encode(self) | |
| return try JSONDecoder().decode(Self.self, from: data) | |
| } | |
| } |