Delegated alternatives and similar libraries
Based on the "Utility" category.
Alternatively, view Delegated alternatives based on common mentions on social networks and blogs.
-
SwifterSwift
A handy collection of more than 500 native Swift extensions to boost your productivity. -
SwiftGen-Storyboard
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
SwiftGen
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
R.swift
Strong typed, autocompleted resources like images, fonts and segues in Swift projects -
swift-protobuf
Plugin and runtime library for using protobuf with Swift -
Dollar
A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript -
DifferenceKit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection. -
EZSwiftExtensions
:smirk: How Swift standard types and classes were supposed to work. -
Result
Swift type modelling the success/failure of arbitrary operations. -
DeepDiff
🦀Amazingly incredible extraordinary lightning fast diffing in Swift -
Device
Light weight tool for detecting the current device and screen size written in swift. -
SwiftLinkPreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images. -
WhatsNew
Showcase new features after an app update similar to Pages, Numbers and Keynote. -
Codextended
Extensions giving Swift's Codable API type inference super powers 🦸♂️🦹♀️ -
Popsicle
Delightful, extensible Swift value interpolation framework. -
SwiftyJSONAccelerator
macOS app to generate Swift 5 code for models from JSON (with Codeable) -
Playbook
📘A library for isolated developing UI components and automatically taking snapshots of them. -
ReadabilityKit
Preview extractor for news, articles and full-texts in Swift -
Compass
:earth_africa: Compass helps you setup a central navigation system for your application -
ObjectiveKit
Swift-friendly API for a set of powerful Objective C runtime functions. -
Bow
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift -
Pythonic.swift
Pythonic tool-belt for Swift – a Swift implementation of selected parts of Python standard library. -
BetterSafariView
A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI. -
SwiftPlantUML
A command-line tool and Swift Package for generating class diagrams powered by PlantUML
Appwrite - The open-source backend cloud platform
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Delegated or a related project?
README
Delegated
Delegated is a super small package that solves the retain cycle problem when dealing with closure-based delegation.
Medium post here.
Usage
Before:
self.downloader = ImageDownloader()
downloader.didDownload = { [weak self] image in
guard let strongSelf = self else {
return
}
strongSelf.currentImage = image
}
After:
self.downloader = ImageDownloader()
downloader.didDownload.delegate(to: self) { (self, image) in
self.currentImage = image
}
No retain cycles! No memory leaks! No [weak self]
! 🎉
Guide
Creating a delegated function
class NumberPrinter {
var numberToString = Delegated<Int, String>()
}
Registering as a delegate
// somewhere inside init() or viewDidLoad() or similar
self.printer = NumberPrinter()
printer.numberToString.delegate(to: self) { (self, number) -> String in
return self.convert(number: number)
}
By default, delegate(to:with:)
will wrap self
in a weak reference so that you don't need to remember to write [weak self]
every time. This is the main feature of Delegated, but if this is not the behavior you want, you can use stronglyDelegated(to:with:)
or manuallyDelegated(with:)
:
self.printer = NumberPrinter()
printer.numberToString.stronglyDelegate(to: self) { (self, number) -> String in
// will hold a strong reference to `self`
return self.convert(number: number)
}
let printer = NumberPrinter()
printer.numberToString.manuallyDelegate(with: { number in
return String(number)
})
Calling a delegate
class NumberPrinter {
var numberToString = Delegated<Int, String>()
func printNumber(_ number: Int) {
// .call returns nil if no delegate was set
guard let string = numberToString.call(number) else {
return
}
print(string)
}
}
Removing a delegate
var numberToString = Delegated<Int, String>()
// ...
numberToString.removeDelegate()
Checking if delegate is set
var numberToString = Delegated<Int, String>()
// ...
numberToString.isDelegateSet // Bool
Installation
Swift Package Manager
Starting with Xcode 11, Delegated is officially available only via Swift Package Manager.
In Xcode 11 or grater, in you project, select: File > Swift Packages > Add Pacakage Dependency
In the search bar type
https://github.com/dreymonde/Delegated
and when you find the package, with the next button you can proceed with the installation.
If you can't find anything in the panel of the Swift Packages you probably haven't added yet your github account. You can do that under the Preferences panel of your Xcode, in the Accounts section.
For command-line based apps, you can just add this directly to your Package.swift file:
dependencies: [
.package(url: "https://github.com/dreymonde/Delegated", from: "0.1.2"),
]
Manual
Of course, you always have an option of just copying-and-pasting the code - Delegated is just one file, so feel free.
Deprecated dependency managers
Last Delegated version to support Carthage and Cocoapods is 0.1.1. Carthage and Cocoapods will no longer be officially supported.
Carthage:
github "dreymonde/Delegated" ~> 0.1.1
Cocoapods:
pod 'Delegated', '~> 0.1.1'
See also
- krzysztofzablocki/Strongify - a 1-file µframework providing a nicer API for avoiding weak-strong dance.