Extensions
The following extensions are available globally.
-
Declaration
Swift
public extension CGFloat -
Declaration
Swift
public extension CGPoint -
Declaration
Swift
public extension CGSize -
Declaration
Swift
public extension CGRect -
Extends the NSObject
See moreDeclaration
Swift
extension NSObject: ClassNameProtocol -
Usage examples:
struct Language: Codable { var name: String var version: String }Create an instance
let language = Language(name: "Swift", version: "5.7")Encode to Data? and decode to a new Language instance
if let data: Data = language.encode() { // use data here... // decode from Data if let lang = Language.decode(from: data) { // use lang here } else { // handle decode error } } else { // handle encode error }Encode instance to String? and decode to a new Language instance
See moreif let string: String = language.encode() { // use string here... // decode from String if let lang = Language.decode(from: string) { // use lang here } else { // handle decode error } } else { // handle encode error }Declaration
Swift
public extension Encodable -
Usage examples: see
See moreextension EncodableDeclaration
Swift
public extension Decodable -
Declaration
Swift
public extension Arraypublic extension Array where Element: Equatablepublic extension Array where Element == String -
Declaration
Swift
public extension Data
-
Declaration
Swift
public extension DateInterval -
Declaration
Swift
public extension Double -
Extension adds a circular iterator to a CaseIterable item, usually an enum
See moreenum MyEnum: CaseIterable { case a, b, c } var letter = MyEnum.a letter.toNext(true) // .b letter.toNext(true) // .c letter.toNext(true) // .a letter.toNext(true) // .b letter.toNext(false) // .a letter.toNext(false) // .cDeclaration
Swift
public extension CaseIterable where Self: Equatable -
Declaration
Swift
public extension FileManager -
Declaration
Swift
public extension Int -
Declaration
Swift
public extension NSAttributedString -
Declaration
Swift
public extension Optional where Wrapped == Int
-
see also https://developer.apple.com/documentation/foundation/nsregularexpression // replace https://gist.github.com/watanabetoshinori/37f5bac79fc3f656f46c8711b6c78257 https://learnappmaking.com/regular-expressions-swift-string/ https://stackoverflow.com/questions/27880650/swift-extract-regex-matches https://www.hackingwithswift.com/articles/108/how-to-use-regular-expressions-in-swift https://www.hackingwithswift.com/articles/154/advanced-regular-expression-matching-with-nsregularexpression https://www.advancedswift.com/regex-capture-groups/
See moreDeclaration
Swift
public extension NSRegularExpression
Extensions Reference