Skip to content

apploft/APLFoundationExtensions

Repository files navigation

APLFoundationExtension

This package provides extensions to commonly used Foundation Classes, like Array and Date.

Everything is written in Swift, documented and tested.

Table of Contents

Overview of Classes and Functionalities

Array Extension

  • Remove duplicate elements.
  • Safely return element.

Date Extension

  • Initialize Date with ease based on year, month, day, minute and second.

DispatchQueue Extension

  • Execute closure associated with a unique token only once and thread safe.

Error Extension

  • Adds code and domain properties to 'Error'.

NSAttributedString Extension

  • Substitute the color of NSAttributedString instance keeping all other attributes.
  • Substitute the text of NSAttributedString instance keeping all other attributes.

String Extension

  • Initialize String with the content of a specified url.
  • Replace fulfilled regex patterns of a String with another String.
  • Determine the capture groups for a given regex.

URLSession

  • Synchronously load data.

UserDefault

A property wrapper for easy access on UserDefault-backed values. See also https://nshipster.com/propertywrapper/

// Define a UserDefault backed value
//
@UserDefault("MyValue", defaultValue: true)
static var myValue: Bool

...

// value will be written to the UserDefaults
myValue = false 

Installation

Just integrate the APLFoundationExtension via Xcode 11 (tutorial).

Usage

After importing APLFoundationExtension all extensions and documentation can be accessed the default way.

An example of using the method subscript(safe: Index) of the Array extension:

import APLFoundationExtension

let array = ["a", "b"]
array[safe: 100] // returns nil

License

APLFoundationExtension is created by apploft on 02.04.2020. Copyright © 2019 apploft GmbH MIT License http://choosealicense.com/licenses/mit/

About

Useful extensions to Apple Foundation classes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages