Swiftpack.co - drekka/UsefulThings as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by drekka.
drekka/UsefulThings 0.0.2
Usefully utilities and classes.
⭐️ 0
🕓 2 weeks ago
iOS macOS tvOS
.package(url: "https://github.com/drekka/UsefulThings.git", from: "0.0.2")


A library of useful bits and pieces.

UserDefaults observing

UserDefaultsObserver is a class you can use to watch a parricular user default for changes. For example if you have a user defaults server.url = (String) "http://abc.com, then you could use this to monitor it for changes:

class MyClass {

    private var observer: UserDefaultsObserver<URL>!

    init() {
        observer = UserDefaultsObserver(key: "server.url") { [weak self]  _, newUrl in
            if let url = newUrl {
                self?.doSomething(with: url)

    func doSomething(with _: URL) {
        // Do something with the new url.


func cast<T>(_ value: Any?) -> T? is a useful little function for casting from one type to a target type. At the moment it's main feature is the ability to cast from a String to a URL by using URL(string:).


Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

A little tweakiness
2 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics