Extensions

The following extensions are available globally.

Formatting of CG structures and scalars

  • Declaration

    Swift

    public extension CGFloat
  • Declaration

    Swift

    public extension CGPoint
  • Declaration

    Swift

    public extension CGSize
  • Declaration

    Swift

    public extension CGRect
  • Extends the NSObject

    See more

    Declaration

    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

    if 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
    }
    
    See more

    Declaration

    Swift

    public extension Encodable
  • Usage examples: see extension Encodable

    See more

    Declaration

    Swift

    public extension Decodable
  • Declaration

    Swift

    public extension Array
    public extension Array where Element: Equatable
    public extension Array where Element == String
  • Declaration

    Swift

    public extension Data

convenience properties and inits

Extended Calendar properties

Extended DateInterval properties

  • Declaration

    Swift

    public extension DateInterval
  • Declaration

    Swift

    public extension Double
  • Extension adds a circular iterator to a CaseIterable item, usually an enum

       enum 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)  // .c
    
    See more

    Declaration

    Swift

    public extension CaseIterable where Self: Equatable
  • Declaration

    Swift

    public extension FileManager
  • Int

    Declaration

    Swift

    public extension Int
  • Declaration

    Swift

    public extension NSAttributedString
  • Declaration

    Swift

    public extension Optional where Wrapped == Int

extension String: general purpose regex methods